MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / parse_array

Function parse_array

eval/LANE_evaluation/lane2d/src/cJSON.c:539–577  ·  view source on GitHub ↗

Build an array from input text. */

Source from the content-addressed store, hash-verified

537
538/* Build an array from input text. */
539static const char *parse_array(cJSON *item, const char *value, const char **ep)
540{
541 cJSON *child;
542 if (*value != '[')
543 {
544 *ep = value;
545 return 0;
546 } /* not an array! */
547
548 item->type = cJSON_Array;
549 value = skip(value + 1);
550 if (*value == ']')
551 return value + 1; /* empty array. */
552
553 item->child = child = cJSON_New_Item();
554 if (!item->child)
555 return 0; /* memory fail */
556 value = skip(parse_value(child, skip(value), ep)); /* skip any spacing, get the value. */
557 if (!value)
558 return 0;
559
560 while (*value == ',')
561 {
562 cJSON *new_item;
563 if (!(new_item = cJSON_New_Item()))
564 return 0; /* memory fail */
565 child->next = new_item;
566 new_item->prev = child;
567 child = new_item;
568 value = skip(parse_value(child, skip(value + 1), ep));
569 if (!value)
570 return 0; /* memory fail */
571 }
572
573 if (*value == ']')
574 return value + 1; /* end of array */
575 *ep = value;
576 return 0; /* malformed. */
577}
578
579/* Render an array to text */
580static char *print_array(cJSON *item, int depth, int fmt)

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