Parse an object - create a new root, and populate. */
| 322 | |
| 323 | /* Parse an object - create a new root, and populate. */ |
| 324 | cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated) |
| 325 | { |
| 326 | const char *end=0; |
| 327 | cJSON *c=cJSON_New_Item(); |
| 328 | ep=0; |
| 329 | if (!c) return 0; /* memory fail */ |
| 330 | |
| 331 | end=parse_value(c,skip(value)); |
| 332 | if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */ |
| 333 | |
| 334 | /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ |
| 335 | if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}} |
| 336 | if (return_parse_end) *return_parse_end=end; |
| 337 | return c; |
| 338 | } |
| 339 | /* Default options for cJSON_Parse */ |
| 340 | cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);} |
| 341 |
no test coverage detected