JSON (JavaScript Object Notation) is a lightweight data-interchange format. It can represents integer, real number, string, an ordered sequence of value, and a collection of name/value pairs.
QJson is a qt-based library that maps JSON data to QVariant objects: JSON arrays will be mapped to QVariantList instances, while JSON objects will be mapped to QVariantMap.
QJson is fast and reliable. Don't waste your time writing another JSON parser!
Converting a JSON object to a QVariant requires just three lines of code:
1 // create a JSonDriver instance 2 QJson::Parser parser; 3 bool ok; 4 5 // json is a QString containing the data to convert 6 QVariant result = parser.parse (json, &ok);
It's also possible to convert QVariant instances to JSON objects:
1 // create a Serializer instance 2 QJson::Serializer serializer; 3 const QByteArray serialized = serializer.serialize( json_object );
It's possible to serialize QObject instances into JSON and also to initialize a QObject using the values stored inside of a JSON object.
Check out the usage section for more code snippets.
QJson is available for the following operative systems: