![]() |
Qt4 JSON API
0.6.0
spt::json
|
This library provides a simple API for representing JSON data. The code is distributed under the Apache Licence, Version 2. This implementation borrows concepts from the Simple JSON Implementation.
The API provides a SAX style spt::json::Parser that invokes call-back methods defined in the spt::json::Handler interface. Client-code may implement their own handler implementations and consume the JSON data into their custom data structures.
The API provides a QVariant based model to represent JSON objects and arrays, as well as a simple DOM parser to parse JSON data into the appropriate data models. The default data model uses shared pointers to represent nested object and array instances to avoid excessive copying of the QVariantHash and QVariantList instances used to store object and array data.
The spt::json::DOMParser implementation provides a generic parse method that parses JSON data from a QIODevice and returns a shared pointer to the object or array representation. This makes it possible to parse JSON data without needing to know whether it is an object or array at compile time.
This is by no means a fully compliant implementation, and in particular we do not support unicode (\uxxxx) characters embedded strings.
In the current implementation only synchronous streams are supported (files, strings, ...). In future we may decide to extend the API to support asynchronous streams (socket) as well.