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