The QJsonObject class encapsulates a JSON object. More...
Header: | #include <QJsonObject> |
qmake: | QT += core |
Since: | Qt 5.0 |
Note: All functions in this class are reentrant.
class | const_iterator |
class | iterator |
typedef | ConstIterator |
typedef | Iterator |
typedef | key_type |
typedef | mapped_type |
typedef | size_type |
QJsonObject() | |
QJsonObject(int args) | |
QJsonObject(const QJsonObject &other) | |
QJsonObject(QJsonObject &&other) | |
~QJsonObject() | |
QJsonObject::iterator | begin() |
QJsonObject::const_iterator | begin() const |
QJsonObject::const_iterator | constBegin() const |
QJsonObject::const_iterator | constEnd() const |
QJsonObject::const_iterator | constFind(const QString &key) const |
QJsonObject::const_iterator | constFind(QLatin1String key) const |
bool | contains(const QString &key) const |
bool | contains(QLatin1String key) const |
int | count() const |
bool | empty() const |
QJsonObject::iterator | end() |
QJsonObject::const_iterator | end() const |
QJsonObject::iterator | erase(QJsonObject::iterator it) |
QJsonObject::iterator | find(const QString &key) |
QJsonObject::iterator | find(QLatin1String key) |
QJsonObject::const_iterator | find(const QString &key) const |
QJsonObject::const_iterator | find(QLatin1String key) const |
QJsonObject::iterator | insert(const QString &key, const QJsonValue &value) |
bool | isEmpty() const |
QStringList | keys() const |
int | length() const |
void | remove(const QString &key) |
int | size() const |
void | swap(QJsonObject &other) |
QJsonValue | take(const QString &key) |
QVariantHash | toVariantHash() const |
QVariantMap | toVariantMap() const |
QJsonValue | value(const QString &key) const |
QJsonValue | value(QLatin1String key) const |
bool | operator!=(const QJsonObject &other) const |
QJsonObject & | operator=(const QJsonObject &other) |
QJsonObject & | operator=(QJsonObject &&other) |
bool | operator==(const QJsonObject &other) const |
QJsonValue | operator[](const QString &key) const |
QJsonValue | operator[](QLatin1String key) const |
QJsonValueRef | operator[](const QString &key) |
QJsonValueRef | operator[](QLatin1String key) |
QJsonObject | fromVariantHash(const QVariantHash &hash) |
QJsonObject | fromVariantMap(const QVariantMap &map) |
The QJsonObject class encapsulates a JSON object.
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.
Qt-style synonym for QJsonObject::const_iterator.
Qt-style synonym for QJsonObject::iterator.
Typedef for QString. Provided for STL compatibility.
Typedef for QJsonValue. Provided for STL compatibility.
Typedef for int. Provided for STL compatibility.
Constructs an empty JSON object.
See also isEmpty().
Constructs a QJsonObject instance initialized from args initialization list. For example:
QJsonObject object { {"property1", 1}, {"property2", 2} };
This function was introduced in Qt 5.4.
Creates a copy of other.
Since QJsonObject is implicitly shared, the copy is shallow as long as the object does not get modified.
Move-constructs a QJsonObject from other.
This function was introduced in Qt 5.10.
Destroys the object.
Returns an STL-style iterator pointing to the first item in the object.
See also constBegin() and end().
This is an overloaded function.
Returns a const STL-style iterator pointing to the first item in the object.
See also begin() and constEnd().
Returns a const STL-style iterator pointing to the imaginary item after the last item in the object.
See also constBegin() and end().
Returns a const iterator pointing to the item with key key in the map.
If the map contains no item with key key, the function returns constEnd().
This is an overloaded function.
This function was introduced in Qt 5.7.
Returns true
if the object contains key key.
See also insert(), remove(), and take().
This is an overloaded function.
This function was introduced in Qt 5.7.
This is an overloaded function.
Same as size().
This function is provided for STL compatibility. It is equivalent to isEmpty(), returning true
if the object is empty; otherwise returning false
.
Returns an STL-style iterator pointing to the imaginary item after the last item in the object.
See also begin() and constEnd().
This is an overloaded function.
Removes the (key, value) pair pointed to by the iterator it from the map, and returns an iterator to the next item in the map.
See also remove().
Returns an iterator pointing to the item with key key in the map.
If the map contains no item with key key, the function returns end().
This is an overloaded function.
This function was introduced in Qt 5.7.
This is an overloaded function.
This is an overloaded function.
This function was introduced in Qt 5.7.
[static]
QJsonObject QJsonObject::fromVariantHash(const QVariantHash &hash)Converts the variant hash hash to a QJsonObject.
The keys in hash will be used as the keys in the JSON object, and the QVariant values will be converted to JSON values.
This function was introduced in Qt 5.5.
See also fromVariantMap(), toVariantHash(), and QJsonValue::fromVariant().
[static]
QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map)Converts the variant map map to a QJsonObject.
The keys in map will be used as the keys in the JSON object, and the QVariant values will be converted to JSON values.
See also fromVariantHash(), toVariantMap(), and QJsonValue::fromVariant().
Inserts a new item with the key key and a value of value.
If there is already an item with the key key, then that item's value is replaced with value.
Returns an iterator pointing to the inserted item.
If the value is QJsonValue::Undefined, it will cause the key to get removed from the object. The returned iterator will then point to end().
See also remove(), take(), QJsonObject::iterator, and end().
Returns true
if the object is empty. This is the same as size() == 0.
See also size().
Returns a list of all keys in this object.
The list is sorted lexographically.
This is an overloaded function.
Same as size().
Removes key from the object.
Returns the number of (key, value) pairs stored in the object.
Swaps the object other with this. This operation is very fast and never fails.
This function was introduced in Qt 5.10.
Removes key from the object.
Returns a QJsonValue containing the value referenced by key. If key was not contained in the object, the returned QJsonValue is QJsonValue::Undefined.
See also insert(), remove(), and QJsonValue.
Converts this object to a QVariantHash.
Returns the created hash.
This function was introduced in Qt 5.5.
See also toVariantMap().
Converts this object to a QVariantMap.
Returns the created map.
See also toVariantHash().
Returns a QJsonValue representing the value for the key key.
The returned QJsonValue is QJsonValue::Undefined if the key does not exist.
See also QJsonValue and QJsonValue::isUndefined().
This is an overloaded function.
This function was introduced in Qt 5.7.
Returns true
if other is not equal to this object.
Assigns other to this object.
Move-assigns other to this object.
This function was introduced in Qt 5.10.
Returns true
if other is equal to this object.
Returns a QJsonValue representing the value for the key key.
This does the same as value().
The returned QJsonValue is QJsonValue::Undefined if the key does not exist.
See also value(), QJsonValue, and QJsonValue::isUndefined().
This is an overloaded function.
This function was introduced in Qt 5.7.
Returns a reference to the value for key.
The return value is of type QJsonValueRef, a helper class for QJsonArray and QJsonObject. When you get an object of type QJsonValueRef, you can use it as if it were a reference to a QJsonValue. If you assign to it, the assignment will apply to the element in the QJsonArray or QJsonObject from which you got the reference.
See also value().
This is an overloaded function.
This function was introduced in Qt 5.7.