libqutim  0.3.1.0
qutim_sdk_0_3::JsonFile Class Reference

#include <jsonfile.h>

Public Member Functions

 JsonFile (const QString &name=QString())
 
virtual ~JsonFile ()
 
bool load (QVariant &variant)
 
bool save (const QVariant &variant)
 
void setFileName (const QString &name)
 

Detailed Description

JsonFile provides high-level api for fast writing and reading files with JSON content.

JsonFile file("test.json");
QVariantMap map;
map.insert("list", QVariantList() << QVariant(1) << QVariant("2"));
map.insert("string", "Hello world!");
file.write(var);

File will contain something like:

{
 "string": "Hello world!",
 "list": [
  1,
  "2"
 ]
}

To read file conents back to QVariant just do:

QVariant var;
JsonFile file("test.json");
file.read(var);
Note
JsonFile is wrapper around methods, provided in Json namespace

Constructor & Destructor Documentation

qutim_sdk_0_3::JsonFile::JsonFile ( const QString &  name = QString())

Constructor.

Parameters
nameFile name
virtual qutim_sdk_0_3::JsonFile::~JsonFile ( )
virtual

Destructor.

Member Function Documentation

bool qutim_sdk_0_3::JsonFile::load ( QVariant &  variant)

Load file's json data to variant.

Returns
True if file was successfully parsed, else false
bool qutim_sdk_0_3::JsonFile::save ( const QVariant &  variant)

Save content of variant as json to file.

Returns
True if file was successfully parsed, else false
void qutim_sdk_0_3::JsonFile::setFileName ( const QString &  name)

Set file name to name.


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

Generated by Doxygen