MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / parse_array

Function parse_array

modules/freeswitch/esl/src/esl_json.c:324–349  ·  view source on GitHub ↗

Build an array from input text. */

Source from the content-addressed store, hash-verified

322
323/* Build an array from input text. */
324static const char *parse_array(cJSON *item,const char *value)
325{
326 cJSON *child;
327 if (*value!='[') {ep=value;return 0;} /* not an array! */
328
329 item->type=cJSON_Array;
330 value=skip(value+1);
331 if (*value==']') return value+1; /* empty array. */
332
333 item->child=child=cJSON_New_Item();
334 if (!item->child) return 0; /* memory fail */
335 value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
336 if (!value) return 0;
337
338 while (*value==',')
339 {
340 cJSON *new_item;
341 if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
342 child->next=new_item;new_item->prev=child;child=new_item;
343 value=skip(parse_value(child,skip(value+1)));
344 if (!value) return 0; /* memory fail */
345 }
346
347 if (*value==']') return value+1; /* end of array */
348 ep=value;return 0; /* malformed. */
349}
350
351/* Render an array to text */
352static char *print_array(cJSON *item,int depth,int fmt)

Callers 1

parse_valueFunction · 0.70

Calls 3

skipFunction · 0.70
cJSON_New_ItemFunction · 0.70
parse_valueFunction · 0.70

Tested by

no test coverage detected