Classified ads
Static Public Member Functions | List of all members
JSonWrapper Class Reference

Class for wrapping engine to (de)serialize json. More...

#include <jsonwrapper.h>

Static Public Member Functions

static QVariantMap parse (const QByteArray &aJSonText, bool *aIsParseOk=NULL, bool aUncompressFirst=false)
 
static QByteArray serialize (const QVariant &aObjectToSerialize, bool aFinallyCompress=false)
 

Detailed Description

Class for wrapping engine to (de)serialize json.

Qt5 has included json routines so if using Qt5 it makes sense to that because it is one dependency less ; with earlier QT versions a 3rd party library is required. This class provides programmer with single API to use json routines regardless of underlying implementation.

Member Function Documentation

static QVariantMap JSonWrapper::parse ( const QByteArray &  aJSonText,
bool *  aIsParseOk = NULL,
bool  aUncompressFirst = false 
)
static

Method that returns aJSonText parsed into a QVariantMap.

Parameters
aJSonTextis text to parse. Must be valid json.
aIsParseOkis set to true/false depending on parse success
aUncompressFirstindication if aJSonText is compressed or not. if compressed, then qUncompress is applied before parser.
Returns
Content of AJSonText as QVariant. Is empty if parse failed so user should check value of aIsParseOk before assuming anything about the content.
static QByteArray JSonWrapper::serialize ( const QVariant &  aObjectToSerialize,
bool  aFinallyCompress = false 
)
static

method that returns QVariant as JSon text.

Parameters
aObjectToSerializeis the object, usually QVariantMap but basically any QVariant should do.
aFinallyCompressif set to true, the returned byte-array is compressed using qCompress()
Returns
serialized stream e.g. json text.

The documentation for this class was generated from the following file: