QJson

the easiest way for managing JSON objects with Qt

Introduction

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.

Easy to use

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:

        // create a JSonDriver instance
        QJson::Parser parser;
        bool ok;

        // json is a QString containing the data to convert
        QVariant result = parser.parse (json, &ok);
        

It's also possible to convert QVariant instances to JSON objects:

          // create a Serializer instance
          QJson::Serializer serializer;
          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 snipplets.