Class for wrapping engine to (de)serialize json.
More...
#include <jsonwrapper.h>
|
static QVariantMap | parse (const QByteArray &aJSonText, bool *aIsParseOk=NULL, bool aUncompressFirst=false) |
|
static QByteArray | serialize (const QVariant &aObjectToSerialize, bool aFinallyCompress=false) |
|
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.
static QVariantMap JSonWrapper::parse |
( |
const QByteArray & |
aJSonText, |
|
|
bool * |
aIsParseOk = NULL , |
|
|
bool |
aUncompressFirst = false |
|
) |
| |
|
static |
Method that returns aJSonText parsed into a QVariantMap.
- Parameters
-
aJSonText | is text to parse. Must be valid json. |
aIsParseOk | is set to true/false depending on parse success |
aUncompressFirst | indication 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
-
aObjectToSerialize | is the object, usually QVariantMap but basically any QVariant should do. |
aFinallyCompress | if 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: