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