Build an array from input text. */
| 322 | |
| 323 | /* Build an array from input text. */ |
| 324 | static 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 */ |
| 352 | static char *print_array(cJSON *item,int depth,int fmt) |
no test coverage detected