Skip to content
This repository was archived by the owner on Mar 26, 2020. It is now read-only.

Commit 4e4eeca

Browse files
committed
Add documentation for chunk parsing.
1 parent c67b94b commit 4e4eeca

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff 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+
4265
More documentation is still to come. For now, see json11.hpp.

0 commit comments

Comments
 (0)