MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / parse_object

Function parse_object

common/map_sdk/transmission/src/cJSON.cpp:525–570  ·  view source on GitHub ↗

Build an object from the text. */

Source from the content-addressed store, hash-verified

523
524/* Build an object from the text. */
525static const char *parse_object(cJSON *item, const char *value) {
526 cJSON *child;
527 if (*value != '{') {
528 ep = value;
529 return 0;
530 } /* not an object! */
531
532 item->type = cJSON_Object;
533 value = skip(value + 1);
534 if (*value == '}') return value + 1; /* empty array. */
535
536 item->child = child = cJSON_New_Item();
537 if (!item->child) return 0;
538 value = skip(parse_string(child, skip(value)));
539 if (!value) return 0;
540 child->string = child->valuestring;
541 child->valuestring = 0;
542 if (*value != ':') {
543 ep = value;
544 return 0;
545 } /* fail! */
546 value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */
547 if (!value) return 0;
548
549 while (*value == ',') {
550 cJSON *new_item;
551 if (!(new_item = cJSON_New_Item())) return 0; /* memory fail */
552 child->next = new_item;
553 new_item->prev = child;
554 child = new_item;
555 value = skip(parse_string(child, skip(value + 1)));
556 if (!value) return 0;
557 child->string = child->valuestring;
558 child->valuestring = 0;
559 if (*value != ':') {
560 ep = value;
561 return 0;
562 } /* fail! */
563 value = skip(parse_value(child, skip(value + 1))); /* skip any spacing, get the value. */
564 if (!value) return 0;
565 }
566
567 if (*value == '}') return value + 1; /* end of array */
568 ep = value;
569 return 0; /* malformed. */
570}
571
572/* Render an object to text. */
573static char *print_object(cJSON *item, int depth, int fmt) {

Callers 1

parse_valueFunction · 0.85

Calls 4

skipFunction · 0.85
cJSON_New_ItemFunction · 0.85
parse_stringFunction · 0.85
parse_valueFunction · 0.85

Tested by

no test coverage detected