Build an object from the text. */
| 392 | |
| 393 | /* Build an object from the text. */ |
| 394 | static const char *parse_object(cJSON *item,const char *value) |
| 395 | { |
| 396 | cJSON *child; |
| 397 | if (*value!='{') {ep=value;return nullptr;} /* not an object! */ |
| 398 | |
| 399 | item->type=cJSON_Object; |
| 400 | value=skip(value+1); |
| 401 | if (*value=='}') return value+1; /* empty array. */ |
| 402 | |
| 403 | item->child=child=cJSON_New_Item(); |
| 404 | if (!item->child) return nullptr; |
| 405 | value=skip(parse_string(child,skip(value))); |
| 406 | if (!value) return nullptr; |
| 407 | child->string=child->valuestring;child->valuestring=nullptr; |
| 408 | if (*value!=':') {ep=value;return nullptr;} /* fail! */ |
| 409 | value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */ |
| 410 | if (!value) return nullptr; |
| 411 | |
| 412 | while (*value==',') |
| 413 | { |
| 414 | cJSON *new_item; |
| 415 | if (!(new_item=cJSON_New_Item())) return nullptr; /* memory fail */ |
| 416 | child->next=new_item;new_item->prev=child;child=new_item; |
| 417 | value=skip(parse_string(child,skip(value+1))); |
| 418 | if (!value) return nullptr; |
| 419 | child->string=child->valuestring;child->valuestring=nullptr; |
| 420 | if (*value!=':') {ep=value;return nullptr;} /* fail! */ |
| 421 | value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */ |
| 422 | if (!value) return nullptr; |
| 423 | } |
| 424 | |
| 425 | if (*value=='}') return value+1; /* end of array */ |
| 426 | ep=value;return nullptr; /* malformed. */ |
| 427 | } |
| 428 | |
| 429 | /* Render an object to text. */ |
| 430 | static char *print_object(cJSON *item,int depth,int fmt) |
no test coverage detected