Parser core - when encountering text, process appropriately. */
| 453 | |
| 454 | /* Parser core - when encountering text, process appropriately. */ |
| 455 | static 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. */ |
| 497 | static char *print_value(cJSON *item, int depth, int fmt) |
no test coverage detected