| 844 | } |
| 845 | |
| 846 | static int agent_json_scan_value(agent_json_scanner_t *scanner, unsigned depth) { |
| 847 | if (depth > AGENT_JSON_MAX_DEPTH || agent_json_skip_space(scanner) != 0 || |
| 848 | scanner->position >= scanner->length) { |
| 849 | return -1; |
| 850 | } |
| 851 | char first = scanner->data[scanner->position]; |
| 852 | if (first == '{') { |
| 853 | return agent_json_scan_object(scanner, depth); |
| 854 | } |
| 855 | if (first == '[') { |
| 856 | return agent_json_scan_array(scanner, depth); |
| 857 | } |
| 858 | if (first == '"' || first == '\'') { |
| 859 | return agent_json_scan_string(scanner, NULL, NULL); |
| 860 | } |
| 861 | size_t start = scanner->position; |
| 862 | while (scanner->position < scanner->length && |
| 863 | !isspace((unsigned char)scanner->data[scanner->position]) && |
| 864 | !strchr(",]}", scanner->data[scanner->position])) { |
| 865 | scanner->position++; |
| 866 | } |
| 867 | return scanner->position > start ? 0 : -1; |
| 868 | } |
| 869 | |
| 870 | static bool agent_json_key_equals(const char *data, size_t start, size_t end, const char *key) { |
| 871 | if (end < start) { |
no test coverage detected