| 435 | } |
| 436 | |
| 437 | void json_delete(JsonNode *node) |
| 438 | { |
| 439 | if (node != nullptr) |
| 440 | { |
| 441 | json_remove_from_parent(node); |
| 442 | |
| 443 | switch (node->tag) |
| 444 | { |
| 445 | case JSON_STRING: |
| 446 | free(node->string_); |
| 447 | break; |
| 448 | case JSON_ARRAY: |
| 449 | case JSON_OBJECT: |
| 450 | { |
| 451 | JsonNode *child, *next; |
| 452 | for (child = node->children.head; child != nullptr; child = next) |
| 453 | { |
| 454 | next = child->next; |
| 455 | json_delete(child); |
| 456 | } |
| 457 | break; |
| 458 | } |
| 459 | default:; |
| 460 | } |
| 461 | |
| 462 | free(node); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | bool json_validate(const char *json) |
| 467 | { |
no test coverage detected