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's objects will be mapped to QVariantMap.
Converting JSON's data to QVariant instance is really simple:
Suppose you're going to convert this JSON data:
{ "encoding" : "UTF-8", "plug-ins" : [ "python", "c++", "ruby" ], "indent" : { "length" : 3, "use_space" : true } }
The following code would convert the JSON data and parse it:
The output would be:
encoding: "UTF-8" plugins: - "python" - "c++" - "ruby" length: 3 use_space: true
The QJson::QObjectHelper class permits to serialize QObject instances into JSON. QJson::QObjectHelper also allows to initialize a QObject using the values stored inside of a JSON object.
QJson build system is based on cmake. Download QJson sources, extract them, move inside the sources directory and then:
hosts this site. |
Send comments to: QJson Developers |