MCPcopy Create free account
hub / github.com/crawl/crawl / parse_array

Function parse_array

crawl-ref/source/json.cc:743–788  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

741}
742
743static 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
779success:
780 *sp = s;
781 if (out)
782 *out = ret;
783 return true;
784
785failure:
786 json_delete(ret);
787 return false;
788}
789
790static bool parse_object(const char **sp, JsonNode **out)
791{

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