Build an array from input text. */
| 329 | |
| 330 | /* Build an array from input text. */ |
| 331 | static const char *parse_array(Json* item,const char *value) |
| 332 | { |
| 333 | Json* child; |
| 334 | if (*value!='[') {ep=value;return 0;} /* not an array! */ |
| 335 | |
| 336 | item->mType=Json::Type_Array; |
| 337 | value=skip(value+1); |
| 338 | if (*value==']') return value+1; /* empty array. */ |
| 339 | |
| 340 | item->mChild=child=New_Item(); |
| 341 | if (!item->mChild) return 0; /* memory fail */ |
| 342 | value = skip(value); |
| 343 | child->mSrcStart = value; |
| 344 | value=skip(parse_value(child,value)); /* skip any spacing, get the value. */ |
| 345 | if (!value) return 0; |
| 346 | |
| 347 | while (*value==',') |
| 348 | { |
| 349 | Json* new_item; |
| 350 | if (!(new_item=New_Item())) return 0; /* memory fail */ |
| 351 | child->mNext=new_item;new_item->mPrev=child;child=new_item; |
| 352 | value = skip(value+1); |
| 353 | child->mSrcStart = value; |
| 354 | value=skip(parse_value(child,value)); |
| 355 | if (!value) return 0; /* memory fail */ |
| 356 | } |
| 357 | |
| 358 | if (*value==']') return value+1; /* end of array */ |
| 359 | ep=value;return 0; /* malformed. */ |
| 360 | } |
| 361 | |
| 362 | /* Render an array to text */ |
| 363 | static char *print_array(Json* item,int depth,int fmt) |
no test coverage detected