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

Function parse_array

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

Build an array from input text. */

Source from the content-addressed store, hash-verified

404
405/* Build an array from input text. */
406static const char *parse_array(cJSON *item,const char *value)
407{
408 cJSON *child;
409 if (*value!='[') {ep=value;return 0;} /* not an array! */
410
411 item->type=cJSON_Array;
412 value=skip(value+1);
413 if (*value==']') return value+1; /* empty array. */
414
415 item->child=child=cJSON_New_Item();
416 if (!item->child) return 0; /* memory fail */
417 value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
418 if (!value) return 0;
419
420 while (*value==',')
421 {
422 cJSON *new_item;
423 if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
424 child->next=new_item;new_item->prev=child;child=new_item;
425 value=skip(parse_value(child,skip(value+1)));
426 if (!value) return 0; /* memory fail */
427 }
428
429 if (*value==']') return value+1; /* end of array */
430 ep=value;return 0; /* malformed. */
431}
432
433/* Render an array to text */
434static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p)

Callers 1

parse_valueFunction · 0.85

Calls 3

skipFunction · 0.85
cJSON_New_ItemFunction · 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…