JSON parsing and emitting.
shows how to parse and emit JSON.
5742{
5744 "{" "\n"
5745 " \"doe\": \"a deer, a female deer\"," "\n"
5746 " \"ray\": \"a drop of golden sun\"," "\n"
5747 " \"me\": \"a name, I call myself\"," "\n"
5748 " \"far\": \"a long long way to go\"" "\n"
5749 "}" "\n"
5750 "";
5751
5752
5754
5755
5756
5758
5761
5762 std::stringstream ss;
5764 CHECK(ss.str() == json);
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5784
5786
5787
5789 "\"doe\": \"a deer, a female deer\"" "\n"
5790 "\"ray\": \"a drop of golden sun\"" "\n"
5791 "\"me\": \"a name, I call myself\"" "\n"
5792 "\"far\": \"a long long way to go\"" "\n"
5793 "");
5794
5795
5797
5799 "doe: a deer, a female deer" "\n"
5800 "ray: a drop of golden sun" "\n"
5801 "me: a name, I call myself" "\n"
5802 "far: a long long way to go" "\n"
5803 "");
5804
5805}
void clear_style(bool recurse=false)
NodeRef rootref()
Get the root as a NodeRef . Note that a non-const Tree implicitly converts to NodeRef.
substr emitrs_json(Tree const &t, id_type id, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
(1) emit+resize: emit JSON to the given std::string/std::vector<char>-like container,...
substr emitrs_yaml(Tree const &t, id_type id, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
(1) emit+resize: emit YAML to the given std::string/std::vector<char>-like container,...
void parse_in_arena(Parser *parser, csubstr filename, csubstr yaml, Tree *tree, id_type node_id)
(1) parse YAML into an existing tree node. The filename will be used in any error messages arising du...
void parse_json_in_arena(Parser *parser, csubstr filename, csubstr json, Tree *tree, id_type node_id)
(1) parse JSON into an existing tree node. The filename will be used in any error messages arising du...
#define CHECK(predicate)
a testing assertion, used only in this quickstart
basic_substring< const char > csubstr
an immutable string view
tag type to mark a tree or node to be emitted as yaml when using operator<<, with options.