MCPcopy Create free account
hub / github.com/acl-dev/acl / parse_object

Function parse_object

lib_acl/samples/json/json5/cJSON.cpp:514–547  ·  view source on GitHub ↗

Build an object from the text. */

Source from the content-addressed store, hash-verified

512
513/* Build an object from the text. */
514static const char *parse_object(cJSON *item,const char *value)
515{
516 cJSON *child;
517 if (*value!='{') {ep=value;return 0;} /* not an object! */
518
519 item->type=cJSON_Object;
520 value=skip(value+1);
521 if (*value=='}') return value+1; /* empty array. */
522
523 item->child=child=cJSON_New_Item();
524 if (!item->child) return 0;
525 value=skip(parse_string(child,skip(value)));
526 if (!value) return 0;
527 child->string=child->valuestring;child->valuestring=0;
528 if (*value!=':') {ep=value;return 0;} /* fail! */
529 value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
530 if (!value) return 0;
531
532 while (*value==',')
533 {
534 cJSON *new_item;
535 if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
536 child->next=new_item;new_item->prev=child;child=new_item;
537 value=skip(parse_string(child,skip(value+1)));
538 if (!value) return 0;
539 child->string=child->valuestring;child->valuestring=0;
540 if (*value!=':') {ep=value;return 0;} /* fail! */
541 value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
542 if (!value) return 0;
543 }
544
545 if (*value=='}') return value+1; /* end of array */
546 ep=value;return 0; /* malformed. */
547}
548
549/* Render an object to text. */
550static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p)

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…