diff --git a/cJSON.c b/cJSON.c index f6dd11c..00df39b 100644 --- a/cJSON.c +++ b/cJSON.c @@ -362,10 +362,12 @@ loop_end: if (number >= INT_MAX) { item->valueint = INT_MAX; + item->valuelong = (long)strtol((const char *)number_c_string, (char **)NULL, 10); } else if (number <= (double)INT_MIN) { item->valueint = INT_MIN; + item->valuelong = (long)strtol((const char *)number_c_string, (char **)NULL, 10); } else { diff --git a/cJSON.h b/cJSON.h index 2628d76..8c8390f 100644 --- a/cJSON.h +++ b/cJSON.h @@ -115,6 +115,7 @@ typedef struct cJSON char *valuestring; /* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */ int valueint; + long valuelong; /* The item's number, if type==cJSON_Number */ double valuedouble;