27#if !defined(_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
28#define _CRT_SECURE_NO_DEPRECATE
32#pragma GCC visibility push(default)
37#pragma warning (disable : 4001)
56#pragma GCC visibility pop
65#define true ((cJSON_bool)1)
70#define false ((cJSON_bool)0)
74#define isinf(d) (isnan((d - d)) && !isnan(d))
77#define isnan(d) (d != d)
95 return (
const char*) (global_error.
json + global_error.
position);
99 if (!cJSON_IsString(
item)) {
107 if (!cJSON_IsNumber(
item)) {
115#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 18)
116#error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
120 static char version[15];
127static int case_insensitive_strcmp(
const unsigned char *string1,
const unsigned char *string2) {
128 if ((string1 ==
NULL) || (string2 ==
NULL)) {
132 if (string1 == string2) {
136 for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++) {
137 if (*string1 ==
'\0') {
142 return tolower(*string1) - tolower(*string2);
160 return realloc(pointer, size);
163#define internal_malloc malloc
164#define internal_free free
165#define internal_realloc realloc
169#define static_strlen(string_literal) (sizeof(string_literal) - sizeof(""))
173static unsigned char* cJSON_strdup(
const unsigned char*
string,
const internal_hooks *
const hooks) {
175 unsigned char *copy =
NULL;
177 if (
string ==
NULL) {
181 length = strlen((
const char*)
string) +
sizeof(
"");
186 memcpy(copy,
string,
length);
195 global_hooks.deallocate = free;
205 global_hooks.deallocate = free;
206 if (hooks->free_fn !=
NULL) {
207 global_hooks.deallocate = hooks->free_fn;
212 if ((global_hooks.
allocate == malloc) && (global_hooks.deallocate == free)) {
221 memset(node,
'\0',
sizeof(
cJSON));
243 global_hooks.deallocate(
item);
249static unsigned char get_decimal_point(
void) {
251 struct lconv *lconv = localeconv();
252 return (
unsigned char) lconv->decimal_point[0];
267#define can_read(buffer, size) ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
269#define can_access_at_index(buffer, index) ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
270#define cannot_access_at_index(buffer, index) (!can_access_at_index(buffer, index))
272#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
277 unsigned char *after_end =
NULL;
278 unsigned char number_c_string[64];
279 unsigned char decimal_point = get_decimal_point();
289 for (i = 0; (i < (
sizeof(number_c_string) - 1)) &&
can_access_at_index(input_buffer, i); i++) {
309 number_c_string[i] = decimal_point;
317 number_c_string[i] =
'\0';
319 number = strtod((
const char*)number_c_string, (
char**)&after_end);
320 if (number_c_string == after_end) {
329 }
else if (
number <= (
double)INT_MIN) {
337 input_buffer->
offset += (size_t)(after_end - number_c_string);
344 object->valueint = INT_MAX;
345 }
else if (
number <= (
double)INT_MIN) {
346 object->valueint = INT_MIN;
348 object->valueint = (int)
number;
351 return object->valuedouble =
number;
371 if (v1_len <= v2_len) {
377 return object->valuestring;
379 copy = (
char*) cJSON_strdup((
const unsigned char*)
valuestring, &global_hooks);
386 object->valuestring = copy;
402static unsigned char* ensure(
printbuffer *
const p,
size_t needed) {
403 unsigned char *newbuffer =
NULL;
415 if (needed > INT_MAX) {
421 if (needed <= p->
length) {
430 if (needed > (INT_MAX / 2)) {
432 if (needed <= INT_MAX) {
438 newsize = needed * 2;
444 if (newbuffer ==
NULL) {
468 return newbuffer + p->
offset;
473 const unsigned char *buffer_pointer =
NULL;
479 buffer->offset += strlen((
const char*)buffer_pointer);
483static cJSON_bool compare_double(
double a,
double b) {
484 double maxVal = fabs(a) > fabs(
b) ? fabs(a) : fabs(
b);
485 return (fabs(a -
b) <= maxVal * DBL_EPSILON);
490 unsigned char *output_pointer =
NULL;
494 unsigned char number_buffer[26] = {0};
495 unsigned char decimal_point = get_decimal_point();
498 if (output_buffer ==
NULL) {
504 length = sprintf((
char*)number_buffer,
"null");
509 length = sprintf((
char*)number_buffer,
"%1.15g", d);
512 if ((sscanf((
char*)number_buffer,
"%lg", &test) != 1) || !compare_double((
double)test, d)) {
514 length = sprintf((
char*)number_buffer,
"%1.17g", d);
519 if ((
length < 0) || (
length > (
int)(
sizeof(number_buffer) - 1))) {
524 output_pointer = ensure(output_buffer, (
size_t)
length +
sizeof(
""));
525 if (output_pointer ==
NULL) {
531 for (i = 0; i < ((size_t)
length); i++) {
532 if (number_buffer[i] == decimal_point) {
533 output_pointer[i] =
'.';
537 output_pointer[i] = number_buffer[i];
539 output_pointer[i] =
'\0';
547static unsigned parse_hex4(
const unsigned char *
const input) {
551 for (i = 0; i < 4; i++) {
553 if ((input[i] >=
'0') && (input[i] <=
'9')) {
554 h += (
unsigned int) input[i] -
'0';
555 }
else if ((input[i] >=
'A') && (input[i] <=
'F')) {
556 h += (
unsigned int) 10 + input[i] -
'A';
557 }
else if ((input[i] >=
'a') && (input[i] <=
'f')) {
558 h += (
unsigned int) 10 + input[i] -
'a';
574static unsigned char utf16_literal_to_utf8(
const unsigned char *
const input_pointer,
const unsigned char *
const input_end,
unsigned char **output_pointer) {
575 long unsigned int codepoint = 0;
576 unsigned int first_code = 0;
577 const unsigned char *first_sequence = input_pointer;
578 unsigned char utf8_length = 0;
579 unsigned char utf8_position = 0;
580 unsigned char sequence_length = 0;
581 unsigned char first_byte_mark = 0;
583 if ((input_end - first_sequence) < 6) {
589 first_code = parse_hex4(first_sequence + 2);
592 if (((first_code >= 0xDC00) && (first_code <= 0xDFFF))) {
597 if ((first_code >= 0xD800) && (first_code <= 0xDBFF)) {
598 const unsigned char *second_sequence = first_sequence + 6;
599 unsigned int second_code = 0;
600 sequence_length = 12;
602 if ((input_end - second_sequence) < 6) {
607 if ((second_sequence[0] !=
'\\') || (second_sequence[1] !=
'u')) {
613 second_code = parse_hex4(second_sequence + 2);
615 if ((second_code < 0xDC00) || (second_code > 0xDFFF)) {
622 codepoint = 0x10000 + (((first_code & 0x3FF) << 10) | (second_code & 0x3FF));
625 codepoint = first_code;
631 if (codepoint < 0x80) {
634 }
else if (codepoint < 0x800) {
637 first_byte_mark = 0xC0;
638 }
else if (codepoint < 0x10000) {
641 first_byte_mark = 0xE0;
642 }
else if (codepoint <= 0x10FFFF) {
645 first_byte_mark = 0xF0;
652 for (utf8_position = (
unsigned char)(utf8_length - 1); utf8_position > 0; utf8_position--) {
654 (*output_pointer)[utf8_position] = (
unsigned char)((codepoint | 0x80) & 0xBF);
658 if (utf8_length > 1) {
659 (*output_pointer)[0] = (
unsigned char)((codepoint | first_byte_mark) & 0xFF);
661 (*output_pointer)[0] = (
unsigned char)(codepoint & 0x7F);
664 *output_pointer += utf8_length;
666 return sequence_length;
676 unsigned char *output_pointer =
NULL;
677 unsigned char *output =
NULL;
686 size_t allocation_length = 0;
687 size_t skipped_bytes = 0;
688 while (((
size_t)(input_end - input_buffer->
content) < input_buffer->
length) && (*input_end !=
'\"')) {
690 if (input_end[0] ==
'\\') {
691 if ((
size_t)(input_end + 1 - input_buffer->
content) >= input_buffer->
length) {
700 if (((
size_t)(input_end - input_buffer->
content) >= input_buffer->
length) || (*input_end !=
'\"')) {
705 allocation_length = (size_t) (input_end -
buffer_at_offset(input_buffer)) - skipped_bytes;
706 output = (
unsigned char*)input_buffer->
hooks.
allocate(allocation_length +
sizeof(
""));
707 if (output ==
NULL) {
712 output_pointer = output;
714 while (input_pointer < input_end) {
715 if (*input_pointer !=
'\\') {
716 *output_pointer++ = *input_pointer++;
720 unsigned char sequence_length = 2;
721 if ((input_end - input_pointer) < 1) {
725 switch (input_pointer[1]) {
727 *output_pointer++ =
'\b';
730 *output_pointer++ =
'\f';
733 *output_pointer++ =
'\n';
736 *output_pointer++ =
'\r';
739 *output_pointer++ =
'\t';
744 *output_pointer++ = input_pointer[1];
749 sequence_length = utf16_literal_to_utf8(input_pointer, input_end, &output_pointer);
750 if (sequence_length == 0) {
759 input_pointer += sequence_length;
764 *output_pointer =
'\0';
769 input_buffer->
offset = (size_t) (input_end - input_buffer->
content);
775 if (output !=
NULL) {
776 input_buffer->
hooks.deallocate(output);
780 if (input_pointer !=
NULL) {
781 input_buffer->
offset = (size_t)(input_pointer - input_buffer->
content);
788static cJSON_bool print_string_ptr(
const unsigned char *
const input,
printbuffer *
const output_buffer) {
789 const unsigned char *input_pointer =
NULL;
790 unsigned char *output =
NULL;
791 unsigned char *output_pointer =
NULL;
792 size_t output_length = 0;
794 size_t escape_characters = 0;
796 if (output_buffer ==
NULL) {
802 output = ensure(output_buffer,
sizeof(
"\"\""));
803 if (output ==
NULL) {
806 strcpy((
char*)output,
"\"\"");
812 for (input_pointer = input; *input_pointer; input_pointer++) {
813 switch (*input_pointer) {
825 if (*input_pointer < 32) {
827 escape_characters += 5;
832 output_length = (size_t)(input_pointer - input) + escape_characters;
834 output = ensure(output_buffer, output_length +
sizeof(
"\"\""));
835 if (output ==
NULL) {
840 if (escape_characters == 0) {
842 memcpy(output + 1, input, output_length);
843 output[output_length + 1] =
'\"';
844 output[output_length + 2] =
'\0';
850 output_pointer = output + 1;
852 for (input_pointer = input; *input_pointer !=
'\0'; (void)input_pointer++, output_pointer++) {
853 if ((*input_pointer > 31) && (*input_pointer !=
'\"') && (*input_pointer !=
'\\')) {
855 *output_pointer = *input_pointer;
858 *output_pointer++ =
'\\';
859 switch (*input_pointer) {
861 *output_pointer =
'\\';
864 *output_pointer =
'\"';
867 *output_pointer =
'b';
870 *output_pointer =
'f';
873 *output_pointer =
'n';
876 *output_pointer =
'r';
879 *output_pointer =
't';
883 sprintf((
char*)output_pointer,
"u%04x", *input_pointer);
889 output[output_length + 1] =
'\"';
890 output[output_length + 2] =
'\0';
968 buffer.content = (
const unsigned char*)value;
971 buffer.hooks = global_hooks;
973 item = cJSON_New_Item(&global_hooks);
978 if (!parse_value(
item, buffer_skip_whitespace(skip_utf8_bom(&
buffer)))) {
985 buffer_skip_whitespace(&
buffer);
1001 if (value !=
NULL) {
1003 local_error.
json = (
const unsigned char*)value;
1008 }
else if (
buffer.length > 0) {
1016 global_error = local_error;
1024 return cJSON_ParseWithOpts(value, 0, 0);
1028 return cJSON_ParseWithLengthOpts(value,
buffer_length, 0, 0);
1031#define cjson_min(a, b) (((a) < (b)) ? (a) : (b))
1034 static const size_t default_buffer_size = 256;
1036 unsigned char *printed =
NULL;
1041 buffer->buffer = (
unsigned char*) hooks->
allocate(default_buffer_size);
1042 buffer->length = default_buffer_size;
1058 if (printed ==
NULL) {
1064 if (printed ==
NULL) {
1068 printed[
buffer->offset] =
'\0';
1071 hooks->deallocate(
buffer->buffer);
1079 hooks->deallocate(
buffer->buffer);
1083 if (printed !=
NULL) {
1084 hooks->deallocate(printed);
1093 return (
char*)print(
item,
true, &global_hooks);
1097 return (
char*)print(
item,
false, &global_hooks);
1101 printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
1116 p.
hooks = global_hooks;
1118 if (!print_value(
item, &p)) {
1119 global_hooks.deallocate(p.
buffer);
1128 printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } };
1139 p.
hooks = global_hooks;
1141 return print_value(
item, &p);
1154 input_buffer->
offset += 4;
1160 input_buffer->
offset += 5;
1167 input_buffer->
offset += 4;
1172 return parse_string(
item, input_buffer);
1176 return parse_number(
item, input_buffer);
1180 return parse_array(
item, input_buffer);
1184 return parse_object(
item, input_buffer);
1192 unsigned char *output =
NULL;
1200 output = ensure(output_buffer, 5);
1201 if (output ==
NULL) {
1204 strcpy((
char*)output,
"null");
1208 output = ensure(output_buffer, 6);
1209 if (output ==
NULL) {
1212 strcpy((
char*)output,
"false");
1216 output = ensure(output_buffer, 5);
1217 if (output ==
NULL) {
1220 strcpy((
char*)output,
"true");
1224 return print_number(
item, output_buffer);
1227 size_t raw_length = 0;
1233 output = ensure(output_buffer, raw_length);
1234 if (output ==
NULL) {
1242 return print_string(
item, output_buffer);
1245 return print_array(
item, output_buffer);
1248 return print_object(
item, output_buffer);
1263 input_buffer->
depth++;
1271 buffer_skip_whitespace(input_buffer);
1288 cJSON *new_item = cJSON_New_Item(&(input_buffer->
hooks));
1289 if (new_item ==
NULL) {
1296 current_item = head = new_item;
1299 current_item->
next = new_item;
1300 new_item->
prev = current_item;
1301 current_item = new_item;
1306 buffer_skip_whitespace(input_buffer);
1307 if (!parse_value(current_item, input_buffer)) {
1310 buffer_skip_whitespace(input_buffer);
1318 input_buffer->
depth--;
1321 head->
prev = current_item;
1341 unsigned char *output_pointer =
NULL;
1345 if (output_buffer ==
NULL) {
1351 output_pointer = ensure(output_buffer, 1);
1352 if (output_pointer ==
NULL) {
1356 *output_pointer =
'[';
1358 output_buffer->
depth++;
1360 while (current_element !=
NULL) {
1361 if (!print_value(current_element, output_buffer)) {
1364 update_offset(output_buffer);
1365 if (current_element->
next) {
1367 output_pointer = ensure(output_buffer,
length + 1);
1368 if (output_pointer ==
NULL) {
1371 *output_pointer++ =
',';
1372 if(output_buffer->
format) {
1373 *output_pointer++ =
' ';
1375 *output_pointer =
'\0';
1378 current_element = current_element->
next;
1381 output_pointer = ensure(output_buffer, 2);
1382 if (output_pointer ==
NULL) {
1385 *output_pointer++ =
']';
1386 *output_pointer =
'\0';
1387 output_buffer->
depth--;
1400 input_buffer->
depth++;
1407 buffer_skip_whitespace(input_buffer);
1423 cJSON *new_item = cJSON_New_Item(&(input_buffer->
hooks));
1424 if (new_item ==
NULL) {
1431 current_item = head = new_item;
1434 current_item->
next = new_item;
1435 new_item->
prev = current_item;
1436 current_item = new_item;
1445 buffer_skip_whitespace(input_buffer);
1446 if (!parse_string(current_item, input_buffer)) {
1449 buffer_skip_whitespace(input_buffer);
1461 buffer_skip_whitespace(input_buffer);
1462 if (!parse_value(current_item, input_buffer)) {
1465 buffer_skip_whitespace(input_buffer);
1473 input_buffer->
depth--;
1476 head->
prev = current_item;
1495 unsigned char *output_pointer =
NULL;
1499 if (output_buffer ==
NULL) {
1505 output_pointer = ensure(output_buffer,
length + 1);
1506 if (output_pointer ==
NULL) {
1510 *output_pointer++ =
'{';
1511 output_buffer->
depth++;
1512 if (output_buffer->
format) {
1513 *output_pointer++ =
'\n';
1517 while (current_item) {
1518 if (output_buffer->
format) {
1520 output_pointer = ensure(output_buffer, output_buffer->
depth);
1521 if (output_pointer ==
NULL) {
1524 for (i = 0; i < output_buffer->
depth; i++) {
1525 *output_pointer++ =
'\t';
1531 if (!print_string_ptr((
unsigned char*)current_item->
string, output_buffer)) {
1534 update_offset(output_buffer);
1537 output_pointer = ensure(output_buffer,
length);
1538 if (output_pointer ==
NULL) {
1541 *output_pointer++ =
':';
1542 if (output_buffer->
format) {
1543 *output_pointer++ =
'\t';
1548 if (!print_value(current_item, output_buffer)) {
1551 update_offset(output_buffer);
1554 length = ((size_t)(output_buffer->
format ? 1 : 0) + (size_t)(current_item->
next ? 1 : 0));
1555 output_pointer = ensure(output_buffer,
length + 1);
1556 if (output_pointer ==
NULL) {
1559 if (current_item->
next) {
1560 *output_pointer++ =
',';
1563 if (output_buffer->
format) {
1564 *output_pointer++ =
'\n';
1566 *output_pointer =
'\0';
1569 current_item = current_item->
next;
1572 output_pointer = ensure(output_buffer, output_buffer->
format ? (output_buffer->
depth + 1) : 2);
1573 if (output_pointer ==
NULL) {
1576 if (output_buffer->
format) {
1578 for (i = 0; i < (output_buffer->
depth - 1); i++) {
1579 *output_pointer++ =
'\t';
1582 *output_pointer++ =
'}';
1583 *output_pointer =
'\0';
1584 output_buffer->
depth--;
1594 if (array ==
NULL) {
1598 child = array->
child;
1600 while(child !=
NULL) {
1602 child = child->
next;
1613 if (array ==
NULL) {
1617 current_child = array->
child;
1618 while ((current_child !=
NULL) && (
index > 0)) {
1620 current_child = current_child->
next;
1623 return current_child;
1631 return get_array_item(array, (
size_t)
index);
1641 current_element =
object->
child;
1643 while ((current_element !=
NULL) && (current_element->
string !=
NULL) && (strcmp(
name, current_element->
string) != 0)) {
1644 current_element = current_element->
next;
1647 while ((current_element !=
NULL) && (case_insensitive_strcmp((
const unsigned char*)
name, (
const unsigned char*)(current_element->
string)) != 0)) {
1648 current_element = current_element->
next;
1652 if ((current_element ==
NULL) || (current_element->
string ==
NULL)) {
1656 return current_element;
1660 return get_object_item(
object,
string,
false);
1663CJSON_PUBLIC(
cJSON *) cJSON_GetObjectItemCaseSensitive(
const cJSON *
const object,
const char *
const string) {
1664 return get_object_item(
object,
string,
true);
1668 return cJSON_GetObjectItem(
object,
string) ? 1 : 0;
1684 reference = cJSON_New_Item(hooks);
1685 if (reference ==
NULL) {
1703 child = array->
child;
1707 if (child ==
NULL) {
1725 return add_item_to_array(array,
item);
1728#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
1729#pragma GCC diagnostic push
1732#pragma GCC diagnostic ignored "-Wcast-qual"
1735static void* cast_away_const(
const void*
string) {
1738#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
1739#pragma GCC diagnostic pop
1744 char *new_key =
NULL;
1752 new_key = (
char*)cast_away_const(
string);
1755 new_key = (
char*)cJSON_strdup((
const unsigned char*)
string, hooks);
1756 if (new_key ==
NULL) {
1760 new_type =
item->
type & ~cJSON_StringIsConst;
1770 return add_item_to_array(
object,
item);
1774 return add_item_to_object(
object,
string,
item, &global_hooks,
false);
1779 return add_item_to_object(
object,
string,
item, &global_hooks,
true);
1783 if (array ==
NULL) {
1787 return add_item_to_array(array, create_reference(
item, &global_hooks));
1791 if ((
object ==
NULL) || (
string ==
NULL)) {
1795 return add_item_to_object(
object,
string, create_reference(
item, &global_hooks), &global_hooks,
false);
1799 cJSON *null = cJSON_CreateNull();
1800 if (add_item_to_object(
object,
name, null, &global_hooks,
false)) {
1809 cJSON *true_item = cJSON_CreateTrue();
1810 if (add_item_to_object(
object,
name, true_item, &global_hooks,
false)) {
1814 cJSON_Delete(true_item);
1819 cJSON *false_item = cJSON_CreateFalse();
1820 if (add_item_to_object(
object,
name, false_item, &global_hooks,
false)) {
1824 cJSON_Delete(false_item);
1829 cJSON *bool_item = cJSON_CreateBool(
boolean);
1830 if (add_item_to_object(
object,
name, bool_item, &global_hooks,
false)) {
1834 cJSON_Delete(bool_item);
1840 if (add_item_to_object(
object,
name, number_item, &global_hooks,
false)) {
1844 cJSON_Delete(number_item);
1849 cJSON *string_item = cJSON_CreateString(
string);
1850 if (add_item_to_object(
object,
name, string_item, &global_hooks,
false)) {
1854 cJSON_Delete(string_item);
1859 cJSON *raw_item = cJSON_CreateRaw(
raw);
1860 if (add_item_to_object(
object,
name, raw_item, &global_hooks,
false)) {
1864 cJSON_Delete(raw_item);
1869 cJSON *object_item = cJSON_CreateObject();
1870 if (add_item_to_object(
object,
name, object_item, &global_hooks,
false)) {
1874 cJSON_Delete(object_item);
1879 cJSON *array = cJSON_CreateArray();
1880 if (add_item_to_object(
object,
name, array, &global_hooks,
false)) {
1884 cJSON_Delete(array);
1922 return cJSON_DetachItemViaPointer(array, get_array_item(array, (
size_t)
which));
1926 cJSON_Delete(cJSON_DetachItemFromArray(array,
which));
1930 cJSON *to_detach = cJSON_GetObjectItem(
object,
string);
1932 return cJSON_DetachItemViaPointer(
object, to_detach);
1936 cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(
object,
string);
1938 return cJSON_DetachItemViaPointer(
object, to_detach);
1941CJSON_PUBLIC(
void) cJSON_DeleteItemFromObject(
cJSON *
object,
const char *
string) {
1942 cJSON_Delete(cJSON_DetachItemFromObject(
object,
string));
1945CJSON_PUBLIC(
void) cJSON_DeleteItemFromObjectCaseSensitive(
cJSON *
object,
const char *
string) {
1946 cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(
object,
string));
1957 after_inserted = get_array_item(array, (
size_t)
which);
1958 if (after_inserted ==
NULL) {
1959 return add_item_to_array(array,
newitem);
1962 if (after_inserted != array->
child && after_inserted->
prev ==
NULL) {
1970 if (after_inserted == array->
child) {
2023 return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (
size_t)
which),
newitem);
2046 return replace_item_in_object(
object,
string,
newitem,
false);
2050 return replace_item_in_object(
object,
string,
newitem,
true);
2055 cJSON *
item = cJSON_New_Item(&global_hooks);
2064 cJSON *
item = cJSON_New_Item(&global_hooks);
2073 cJSON *
item = cJSON_New_Item(&global_hooks);
2082 cJSON *
item = cJSON_New_Item(&global_hooks);
2091 cJSON *
item = cJSON_New_Item(&global_hooks);
2097 if (num >= INT_MAX) {
2099 }
else if (num <= (
double)INT_MIN) {
2110 cJSON *
item = cJSON_New_Item(&global_hooks);
2124 cJSON *
item = cJSON_New_Item(&global_hooks);
2134 cJSON *
item = cJSON_New_Item(&global_hooks);
2144 cJSON *
item = cJSON_New_Item(&global_hooks);
2154 cJSON *
item = cJSON_New_Item(&global_hooks);
2168 cJSON *
item = cJSON_New_Item(&global_hooks);
2177 cJSON *
item = cJSON_New_Item(&global_hooks);
2196 a = cJSON_CreateArray();
2198 for(i = 0; a && (i < (size_t)
count); i++) {
2199 n = cJSON_CreateNumber(numbers[i]);
2207 suffix_object(p, n);
2212 if (a && a->
child) {
2229 a = cJSON_CreateArray();
2231 for(i = 0; a && (i < (size_t)
count); i++) {
2232 n = cJSON_CreateNumber((
double)numbers[i]);
2240 suffix_object(p, n);
2245 if (a && a->
child) {
2262 a = cJSON_CreateArray();
2264 for(i = 0; a && (i < (size_t)
count); i++) {
2265 n = cJSON_CreateNumber(numbers[i]);
2273 suffix_object(p, n);
2278 if (a && a->
child) {
2295 a = cJSON_CreateArray();
2297 for (i = 0; a && (i < (size_t)
count); i++) {
2298 n = cJSON_CreateString(strings[i]);
2311 if (a && a->
child) {
2336 newitem = cJSON_New_Item(&global_hooks);
2362 while (child !=
NULL) {
2372 next->
next = newchild;
2373 newchild->
prev = next;
2380 child = child->
next;
2396static void skip_oneline_comment(
char **input) {
2399 for (; (*input)[0] !=
'\0'; ++(*input)) {
2400 if ((*input)[0] ==
'\n') {
2407static void skip_multiline_comment(
char **input) {
2410 for (; (*input)[0] !=
'\0'; ++(*input)) {
2411 if (((*input)[0] ==
'*') && ((*input)[1] ==
'/')) {
2418static void minify_string(
char **input,
char **output) {
2419 (*output)[0] = (*input)[0];
2424 for (; (*input)[0] !=
'\0'; (void)++(*input), ++(*output)) {
2425 (*output)[0] = (*input)[0];
2427 if ((*input)[0] ==
'\"') {
2428 (*output)[0] =
'\"';
2432 }
else if (((*input)[0] ==
'\\') && ((*input)[1] ==
'\"')) {
2433 (*output)[1] = (*input)[1];
2447 while (json[0] !=
'\0') {
2457 if (json[1] ==
'/') {
2458 skip_oneline_comment(&json);
2459 }
else if (json[1] ==
'*') {
2460 skip_multiline_comment(&json);
2467 minify_string(&json, (
char**)&into);
2567 switch (a->
type & 0xFF) {
2587 switch (a->
type & 0xFF) {
2615 for (; (a_element !=
NULL) && (b_element !=
NULL);) {
2620 a_element = a_element->
next;
2621 b_element = b_element->
next;
2625 if (a_element != b_element) {
2638 if (b_element ==
NULL) {
2651 if (a_element ==
NULL) {
2669 return global_hooks.
allocate(size);
2673 global_hooks.deallocate(
object);
#define can_read(buffer, size)
CJSON_PUBLIC(const char *)
#define static_strlen(string_literal)
struct internal_hooks internal_hooks
#define cannot_access_at_index(buffer, index)
cJSON * cJSON_Duplicate_rec(const cJSON *item, size_t depth, cJSON_bool recurse)
#define buffer_at_offset(buffer)
#define can_access_at_index(buffer, index)
const char *const const double number
const cJSON *const const cJSON_bool case_sensitive
#define CJSON_CIRCULAR_LIMIT
cJSON *const cJSON * replacement
#define cJSON_StringIsConst
#define CJSON_VERSION_MINOR
const char cJSON_bool require_null_terminated
#define CJSON_VERSION_PATCH
const char ** return_parse_end
const char *const const char *const raw
#define CJSON_VERSION_MAJOR
#define CJSON_NESTING_LIMIT
#define cJSON_ArrayForEach(element, array)
#define cJSON_IsReference
char const int const cJSON_bool format
void *CJSON_CDECL * malloc_fn(size_t sz)
const unsigned char * json
void(CJSON_CDECL *deallocate)(void *pointer)
void *CJSON_CDECL * reallocate(void *pointer, size_t size)
void *CJSON_CDECL * allocate(size_t size)
const unsigned char * content