Build an array from input text. */
| 313 | |
| 314 | /* Build an array from input text. */ |
| 315 | static const char *parse_array(cJSON *item,const char *value) |
| 316 | { |
| 317 | cJSON *child; |
| 318 | if (*value!='[') {ep=value;return nullptr;} /* not an array! */ |
| 319 | |
| 320 | item->type=cJSON_Array; |
| 321 | value=skip(value+1); |
| 322 | if (*value==']') return value+1; /* empty array. */ |
| 323 | |
| 324 | item->child=child=cJSON_New_Item(); |
| 325 | if (!item->child) return nullptr; /* memory fail */ |
| 326 | value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */ |
| 327 | if (!value) return nullptr; |
| 328 | |
| 329 | while (*value==',') |
| 330 | { |
| 331 | cJSON *new_item; |
| 332 | if (!(new_item=cJSON_New_Item())) return nullptr; /* memory fail */ |
| 333 | child->next=new_item;new_item->prev=child;child=new_item; |
| 334 | value=skip(parse_value(child,skip(value+1))); |
| 335 | if (!value) return nullptr; /* memory fail */ |
| 336 | } |
| 337 | |
| 338 | if (*value==']') return value+1; /* end of array */ |
| 339 | ep=value;return nullptr; /* malformed. */ |
| 340 | } |
| 341 | |
| 342 | /* Render an array to text */ |
| 343 | static char *print_array(cJSON *item,int depth,int fmt) |
no test coverage detected