QJsonObject Class

The QJsonObject class encapsulates a JSON object. More...

Header: #include <QJsonObject>
qmake: QT += core
Since: Qt 5.0

This class was introduced in Qt 5.0.

Note: All functions in this class are reentrant.

Public Types

class const_iterator
class iterator
typedef ConstIterator
typedef Iterator
typedef key_type
typedef mapped_type
typedef size_type

Detailed Description

A JSON object is a list of key value pairs, where the keys are unique strings and the values are represented by a QJsonValue.

A QJsonObject can be converted to and from a QVariantMap. You can query the number of (key, value) pairs with size(), insert(), and remove() entries from it and iterate over its content using the standard C++ iterator pattern.

QJsonObject is an implicitly shared class, and shares the data with the document it has been created from as long as it is not being modified.

You can convert the object to and from text based JSON through QJsonDocument.

See also JSON Support in Qt and JSON Save Game Example.

Member Type Documentation

typedef QJsonObject::ConstIterator

Qt-style synonym for QJsonObject::const_iterator.

typedef QJsonObject::Iterator

Qt-style synonym for QJsonObject::iterator.

typedef QJsonObject::key_type

Typedef for QString. Provided for STL compatibility.

typedef QJsonObject::mapped_type

Typedef for QJsonValue. Provided for STL compatibility.

typedef QJsonObject::size_type

Typedef for int. Provided for STL compatibility.