| 741 | } |
| 742 | |
| 743 | static bool parse_array(const char **sp, JsonNode **out) |
| 744 | { |
| 745 | const char *s = *sp; |
| 746 | JsonNode *ret = out ? json_mkarray() : nullptr; |
| 747 | JsonNode *element; |
| 748 | |
| 749 | if (*s++ != '[') |
| 750 | goto failure; |
| 751 | skip_space(&s); |
| 752 | |
| 753 | if (*s == ']') |
| 754 | { |
| 755 | s++; |
| 756 | goto success; |
| 757 | } |
| 758 | |
| 759 | for (;;) |
| 760 | { |
| 761 | if (!parse_value(&s, out ? &element : nullptr)) |
| 762 | goto failure; |
| 763 | skip_space(&s); |
| 764 | |
| 765 | if (out) |
| 766 | json_append_element(ret, element); |
| 767 | |
| 768 | if (*s == ']') |
| 769 | { |
| 770 | s++; |
| 771 | goto success; |
| 772 | } |
| 773 | |
| 774 | if (*s++ != ',') |
| 775 | goto failure; |
| 776 | skip_space(&s); |
| 777 | } |
| 778 | |
| 779 | success: |
| 780 | *sp = s; |
| 781 | if (out) |
| 782 | *out = ret; |
| 783 | return true; |
| 784 | |
| 785 | failure: |
| 786 | json_delete(ret); |
| 787 | return false; |
| 788 | } |
| 789 | |
| 790 | static bool parse_object(const char **sp, JsonNode **out) |
| 791 | { |
no test coverage detected