MCPcopy Create free account
hub / github.com/Snapchat/Valdi / parse_array

Function parse_array

compiler/compiler/Compiler/Vendors/Clibsass/Sources/json.cpp:733–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

731}
732
733static bool parse_array(const char **sp, JsonNode **out)
734{
735 const char *s = *sp;
736 JsonNode *ret = out ? json_mkarray() : NULL;
737 JsonNode *element = NULL;
738
739 if (*s++ != '[')
740 goto failure;
741 skip_space(&s);
742
743 if (*s == ']') {
744 s++;
745 goto success;
746 }
747
748 for (;;) {
749 if (!parse_value(&s, out ? &element : NULL))
750 goto failure;
751 skip_space(&s);
752
753 if (out)
754 json_append_element(ret, element);
755
756 if (*s == ']') {
757 s++;
758 goto success;
759 }
760
761 if (*s++ != ',')
762 goto failure;
763 skip_space(&s);
764 }
765
766success:
767 *sp = s;
768 if (out)
769 *out = ret;
770 return true;
771
772failure:
773 json_delete(ret);
774 return false;
775}
776
777static bool parse_object(const char **sp, JsonNode **out)
778{

Callers 1

parse_valueFunction · 0.85

Calls 5

json_mkarrayFunction · 0.85
skip_spaceFunction · 0.85
parse_valueFunction · 0.85
json_append_elementFunction · 0.85
json_deleteFunction · 0.85

Tested by

no test coverage detected