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

Commit

Permalink
Add documentation for chunk parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
canatella committed Jan 6, 2017
1 parent c67b94b commit 4e4eeca
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,27 @@ JSON values can have their values queried and inspected:
Json json = Json::array { Json::object { { "k", "v" } } };
std::string str = json[0]["k"].string_value();

## Parsing

To parse a string, you can simply call

Json json = Json::parse("{ \"key\": \"value1\" }");

If you need to parse json data in multiple step, because you are
using non-blocking io for example, you can create a parser object. It will hold
the parsing state and you can give it the data as it comes along:

JsonParser parser;
std::string data = read_data();
while (!data.empty()) {
parse.consume(data);
}

if (!parser.last_error().empty()) {
/* an error occured */
...
}

Json json = parser.json();

More documentation is still to come. For now, see json11.hpp.

0 comments on commit 4e4eeca

Please sign in to comment.