MCPcopy Index your code
hub / github.com/armink/struct2json / cJSON_ParseWithOpts

Function cJSON_ParseWithOpts

struct2json/src/cJSON.c:324–338  ·  view source on GitHub ↗

Parse an object - create a new root, and populate. */

Source from the content-addressed store, hash-verified

322
323/* Parse an object - create a new root, and populate. */
324cJSON *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 */
340cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);}
341

Callers 1

cJSON_ParseFunction · 0.85

Calls 4

cJSON_New_ItemFunction · 0.85
parse_valueFunction · 0.85
skipFunction · 0.85
cJSON_DeleteFunction · 0.85

Tested by

no test coverage detected