Bjorn Reese wrote:
On 04/10/2013 11:46 PM, Stephan Bourgeois wrote:
Open Source JSON parsers have already been implemented in C++ and in Java. Examples of Java libraries are: Gson, quick-json. Even if other libraries already exist, developers who are using Boost for their project will appreciate having a JSON parser within Boost.
Agreed.
The question is what data structure we should use to represent JSON objects, and how the user can access key/value pairs in those objects. (examples: Boost.PropertyTree, pre-existing C++ object, ...)
I would like to have several different interfaces:
1. Tokenizer API which reads the next token from an input string. This is important for streaming data.
2. Iterator API which iterates to the next token in the input string. Remembers its parent scopes (unlike tokenizer.) This is similar to the XmlTextReader API.
3. Tree API which parses the entire input string into a tree structure. This is a bit like the DOM API, and this is what the Spirit example and Boost.PropertyTree provides.
4. Serialization API which provides a Boost.Serialization input archive without going through an intermediate tree representation.
I would think to add perhaps a fusion API which I think should allow you to have a usage similar to that of JsonFX in C# for any fusion adapted type. http://codepad.org/mu0VD9LG