CopperSpice API
1.9.2
|
The QJsonObject class encapsulates a JSON object. More...
Public Typedefs | |
using | const_iterator = QFlatMap< QString, QJsonValue >::const_iterator |
using | iterator = QFlatMap< QString, QJsonValue >::iterator |
using | key_type = QString |
using | mapped_type = QJsonValue |
using | size_type = QFlatMap< QString, QJsonValue >::size_type |
Public Methods | |
QJsonObject () | |
QJsonObject (const QJsonObject &other) | |
QJsonObject (const_iterator iter_begin, const_iterator iter_end) | |
QJsonObject (QJsonObject &&other) | |
QJsonObject (std::initializer_list< QPair< QString, QJsonValue >> list) | |
~QJsonObject () | |
iterator | begin () |
const_iterator | begin () const |
const_iterator | constBegin () const |
const_iterator | constEnd () const |
const_iterator | constFind (const QString &key) const |
bool | contains (const QString &key) const |
int | count () const |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
iterator | erase (const_iterator iter) |
iterator | find (const QString &key) |
const_iterator | find (const QString &key) const |
iterator | insert (const QString &key, QJsonValue value) |
bool | isEmpty () const |
QStringList | keys () const |
int | length () const |
bool | operator!= (const QJsonObject &other) const |
QJsonObject & | operator= (const QJsonObject &other) |
bool | operator== (const QJsonObject &other) const |
QJsonValue & | operator[] (const QString &key) |
const QJsonValue & | operator[] (const QString &key) const |
void | remove (const QString &key) |
size_type | size () const |
QJsonValue | take (const QString &key) |
QVariantHash | toVariantHash () const |
QVariantMap | toVariantMap () const |
const QJsonValue & | value (const QString &key) const |
Static Public Methods | |
static QJsonObject | fromVariantHash (const QVariantHash &hash) |
static QJsonObject | fromVariantMap (const QVariantMap &map) |
Friends | |
class | QJsonValue |
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 QVariantHash or 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.
The object can be converted to and from a text based JSON format through QJsonDocument.
Equivalent to QFlatMap<QString, QJsonValue>::const_iterator.
Equivalent to QFlatMap<QString, QJsonValue>::iterator.
Equivalent to QString.
Equivalent to QJsonValue.
Equivalent to int.
QJsonObject::QJsonObject | ( | ) |
Constructs an empty JSON object.
QJsonObject::QJsonObject | ( | const_iterator | iter_begin, |
const_iterator | iter_end | ||
) |
Constructs a QJsonArray using an iterator range.
QJsonObject::QJsonObject | ( | std::initializer_list< QPair< QString, QJsonValue >> | list | ) |
Constructs a QJsonObject initialized from list.
QJsonObject::QJsonObject | ( | const QJsonObject & | other | ) |
Copy constructs a new QJsonObject from other.
QJsonObject::QJsonObject | ( | QJsonObject && | other | ) |
Move constructs a new QJsonObject from other.
QJsonObject::~QJsonObject | ( | ) |
Destroys this object.
iterator QJsonObject::begin | ( | ) |
Returns an STL-style iterator pointing to the first item in the object.
const_iterator QJsonObject::begin | ( | ) | const |
Returns an STL-style const iterator pointing to the first item in the object.
const_iterator QJsonObject::constBegin | ( | ) | const |
Returns a const STL-style const iterator pointing to the first item in the object.
const_iterator QJsonObject::constEnd | ( | ) | const |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the object.
const_iterator QJsonObject::constFind | ( | const QString & | key | ) | const |
Returns a const iterator pointing to the item with the given key. If the object contains no item with key, returns end.
bool QJsonObject::contains | ( | const QString & | key | ) | const |
|
inline |
Equivalent to calling size().
|
inline |
Equivalent to isEmpty(), returning true
if the object is empty, otherwise returning false
.
iterator QJsonObject::end | ( | ) |
Returns an STL-style iterator pointing to the imaginary item after the last item in the object.
const_iterator QJsonObject::end | ( | ) | const |
Returns an STL-style const iterator pointing to the imaginary item after the last item in the object.
iterator QJsonObject::erase | ( | const_iterator | iter | ) |
Returns an iterator pointing to the item with the given key. If the object contains no item with key, returns end.
|
inline |
Returns a const iterator pointing to the item with the given key. If the object contains no item with key, returns end.
|
static |
Converts the variant 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.
|
static |
Converts the variant 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.
iterator QJsonObject::insert | ( | const QString & | key, |
QJsonValue | value | ||
) |
Inserts a new item with the string key and a JsonValue of value. If there is already an item with the key the item's value is replaced with the new value. Returns an iterator pointing to the inserted item.
If the value is QJsonValue::Undefined the key will be removed from the object. The returned iterator points to end().
bool QJsonObject::isEmpty | ( | ) | const |
QStringList QJsonObject::keys | ( | ) | const |
Returns a list of all keys in this object.
|
inline |
Equivalent to calling size().
bool QJsonObject::operator!= | ( | const QJsonObject & | other | ) | const |
Returns true if other is not equal to this object.
QJsonObject & QJsonObject::operator= | ( | const QJsonObject & | other | ) |
Copy assigns from other and returns a reference to this object.
bool QJsonObject::operator== | ( | const QJsonObject & | other | ) | const |
Returns true if other is equal to this object.
QJsonValue & QJsonObject::operator[] | ( | const QString & | key | ) |
Returns a reference to the value for key. The return value is of type QJsonValue.
const QJsonValue & QJsonObject::operator[] | ( | const QString & | key | ) | const |
Returns a QJsonValue representing the value the given key. Equivalent to calling value(). The returned QJsonValue is QJsonValue::Undefined if the key does not exist.
void QJsonObject::remove | ( | const QString & | key | ) |
size_type QJsonObject::size | ( | ) | const |
Returns the number of (key, value) pairs stored in this object.
QJsonValue QJsonObject::take | ( | const QString & | key | ) |
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().
QVariantHash QJsonObject::toVariantHash | ( | ) | const |
Converts this object to a QVariantHash. Returns the created hash.
QVariantMap QJsonObject::toVariantMap | ( | ) | const |
Converts this object to a QVariantMap. Returns the created map.
const QJsonValue & QJsonObject::value | ( | const QString & | key | ) | const |
Returns a QJsonValue representing the value for the given key. The returned QJsonValue is QJsonValue::Undefined if the key does not exist.