This repository was archived by the owner on Mar 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,4 +39,27 @@ JSON values can have their values queried and inspected:
3939 Json json = Json::array { Json::object { { "k", "v" } } };
4040 std::string str = json[0]["k"].string_value();
4141
42+ ## Parsing
43+
44+ To parse a string, you can simply call
45+
46+ Json json = Json::parse("{ \"key\": \"value1\" }");
47+
48+ If you need to parse json data in multiple step, because you are
49+ using non-blocking io for example, you can create a parser object. It will hold
50+ the parsing state and you can give it the data as it comes along:
51+
52+ JsonParser parser;
53+ std::string data = read_data();
54+ while (!data.empty()) {
55+ parse.consume(data);
56+ }
57+
58+ if (!parser.last_error().empty()) {
59+ /* an error occured */
60+ ...
61+ }
62+
63+ Json json = parser.json();
64+
4265More documentation is still to come. For now, see json11.hpp.
You can’t perform that action at this time.
0 commit comments