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

Function parse_value

struct2json/src/cJSON.c:358–370  ·  view source on GitHub ↗

Parser core - when encountering text, process appropriately. */

Source from the content-addressed store, hash-verified

356
357/* Parser core - when encountering text, process appropriately. */
358static const char *parse_value(cJSON *item,const char *value)
359{
360 if (!value) return 0; /* Fail on null. */
361 if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
362 if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
363 if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
364 if (*value=='\"') { return parse_string(item,value); }
365 if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
366 if (*value=='[') { return parse_array(item,value); }
367 if (*value=='{') { return parse_object(item,value); }
368
369 ep=value;return 0; /* failure. */
370}
371
372/* Render a value to text. */
373static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p)

Callers 3

cJSON_ParseWithOptsFunction · 0.85
parse_arrayFunction · 0.85
parse_objectFunction · 0.85

Calls 4

parse_stringFunction · 0.85
parse_numberFunction · 0.85
parse_arrayFunction · 0.85
parse_objectFunction · 0.85

Tested by

no test coverage detected