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

Function parse_value

crawl-ref/source/json.cc:663–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

661}
662
663static bool parse_value(const char **sp, JsonNode **out)
664{
665 const char *s = *sp;
666
667 switch (*s)
668 {
669 case 'n':
670 if (expect_literal(&s, "null"))
671 {
672 if (out)
673 *out = json_mknull();
674 *sp = s;
675 return true;
676 }
677 return false;
678
679 case 'f':
680 if (expect_literal(&s, "false"))
681 {
682 if (out)
683 *out = json_mkbool(false);
684 *sp = s;
685 return true;
686 }
687 return false;
688
689 case 't':
690 if (expect_literal(&s, "true"))
691 {
692 if (out)
693 *out = json_mkbool(true);
694 *sp = s;
695 return true;
696 }
697 return false;
698
699 case '"':
700 {
701 char *str;
702 if (parse_string(&s, out ? &str : nullptr))
703 {
704 if (out)
705 *out = mkstring(str);
706 *sp = s;
707 return true;
708 }
709 return false;
710 }
711
712 case '[':
713 if (parse_array(&s, out))
714 {
715 *sp = s;
716 return true;
717 }
718 return false;
719
720 case '{':

Callers 4

json_decodeFunction · 0.85
json_validateFunction · 0.85
parse_arrayFunction · 0.85
parse_objectFunction · 0.85

Calls 9

expect_literalFunction · 0.85
json_mknullFunction · 0.85
json_mkboolFunction · 0.85
parse_stringFunction · 0.85
mkstringFunction · 0.85
parse_arrayFunction · 0.85
parse_objectFunction · 0.85
parse_numberFunction · 0.85
json_mknumberFunction · 0.85

Tested by

no test coverage detected