MCPcopy Create free account
hub / github.com/Bwar/CJsonObject / parse_value

Function parse_value

cJSON.c:455–494  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

453
454/* Parser core - when encountering text, process appropriately. */
455static const char *parse_value(cJSON *item, const char *value, const char **ep)
456{
457 if (!value)
458 return 0; /* Fail on null. */
459 if (!strncmp(value, "null", 4))
460 {
461 item->type = cJSON_NULL;
462 return value + 4;
463 }
464 if (!strncmp(value, "false", 5))
465 {
466 item->type = cJSON_False;
467 return value + 5;
468 }
469 if (!strncmp(value, "true", 4))
470 {
471 item->type = cJSON_True;
472 item->valueint = 1;
473 return value + 4;
474 }
475 if (*value == '\"')
476 {
477 return parse_string(item, value, ep);
478 }
479 if (*value == '-' || (*value >= '0' && *value <= '9'))
480 {
481 return parse_number(item, value);
482 }
483 if (*value == '[')
484 {
485 return parse_array(item, value, ep);
486 }
487 if (*value == '{')
488 {
489 return parse_object(item, value, ep);
490 }
491
492 *ep = value;
493 return 0; /* failure. */
494}
495
496/* Render a value to text. */
497static char *print_value(cJSON *item, int depth, int fmt)

Callers 3

cJSON_ParseFunction · 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