The QJsonObject class encapsulates a JSON object. 更多...
头: | #include <QJsonObject> |
qmake: | QT += core |
Since: | Qt 5.0 |
注意: 此类的所有函数 可重入 .
class | const_iterator |
class | iterator |
typedef | ConstIterator |
typedef | Iterator |
typedef | key_type |
typedef | mapped_type |
typedef | size_type |
QJsonObject () | |
QJsonObject (std::initializer_list<QPair<QString, QJsonValue> > args ) | |
QJsonObject (const QJsonObject & other ) | |
~QJsonObject () | |
iterator | begin () |
const_iterator | begin () const |
const_iterator | constBegin () const |
const_iterator | constEnd () const |
const_iterator | constFind (const QString & key ) const |
const_iterator | constFind (QLatin1String key ) const |
bool | contains (const QString & key ) const |
bool | contains (QLatin1String key ) const |
int | count () const |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
iterator | erase (iterator it ) |
iterator | find (const QString & key ) |
iterator | find (QLatin1String key ) |
const_iterator | find (const QString & key ) const |
const_iterator | find (QLatin1String key ) const |
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 |
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 ) |
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 (),和 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 .
另请参阅 在 Qt 中支持 JSON and JSON 保存游戏范例 .
Qt 样式同义词 QJsonObject::const_iterator .
Qt 样式同义词 QJsonObject::iterator .
typedef 对于 QString . Provided for STL compatibility.
typedef 对于 QJsonValue . Provided for STL compatibility.
typedef 对于 int。为兼容 STL 提供。
构造空的 JSON 对象。
另请参阅 isEmpty ().
构造 QJsonObject instance initialized from args initialization list. For example:
QJsonObject object { {"property1", 1}, {"property2", 2} };
该函数在 Qt 5.4 引入。
创建副本为 other .
由于 QJsonObject is implicitly shared, the copy is shallow as long as the object does not get modified.
销毁对象。
返回 STL 样式迭代器 pointing to the first item in the object.
另请参阅 constBegin () 和 end ().
这是重载函数。
返回常量 STL 样式迭代器 pointing to the first item in the object.
返回常量 STL 样式迭代器 pointing to the imaginary item after the last item in the object.
另请参阅 constBegin () 和 end ().
Returns a const iterator pointing to the item with key key in the map.
If the map contains no item with key key ,函数返回 constEnd ().
这是重载函数。
该函数在 Qt 5.7 引入。
返回
true
if the object contains key
key
.
另请参阅 insert (), remove (),和 take ().
这是重载函数。
该函数在 Qt 5.7 引入。
这是重载函数。
如同 size ().
此函数为兼容 STL (标准模板库) 提供。它相当于
isEmpty
(), returning
true
if the object is empty; otherwise returning
false
.
返回 STL 样式迭代器 pointing to the imaginary item after the last item in the object.
这是重载函数。
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.
另请参阅 remove ().
Returns an iterator pointing to the item with key key in the map.
If the map contains no item with key key ,函数返回 end ().
这是重载函数。
该函数在 Qt 5.7 引入。
这是重载函数。
这是重载函数。
该函数在 Qt 5.7 引入。
[static]
QJsonObject
QJsonObject::
fromVariantHash
(const
QVariantHash
&
hash
)
Converts the variant hash hash 到 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.
该函数在 Qt 5.5 引入。
另请参阅 fromVariantMap (), toVariantHash (),和 QJsonValue::fromVariant ().
[static]
QJsonObject
QJsonObject::
fromVariantMap
(const
QVariantMap
&
map
)
Converts the variant map map 到 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.
另请参阅 fromVariantHash (), toVariantMap (),和 QJsonValue::fromVariant ().
Inserts a new item with the key key 和值 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 ().
另请参阅 remove (), take (), QJsonObject::iterator ,和 end ().
返回
true
if the object is empty. This is the same as
size
() == 0.
另请参阅 size ().
返回在此对象中的所有键列表。
The list is sorted lexographically.
这是重载函数。
如同 size ().
移除 key 从对象。
Returns the number of (key, value) pairs stored in the object.
移除 key 从对象。
返回 QJsonValue containing the value referenced by key 。若 key was not contained in the object, the returned QJsonValue is QJsonValue::Undefined .
另请参阅 insert (), remove (),和 QJsonValue .
把此对象转换成 QVariantHash .
返回创建的哈希。
该函数在 Qt 5.5 引入。
另请参阅 toVariantMap ().
把此对象转换成 QVariantMap .
返回创建的映射。
另请参阅 toVariantHash ().
返回 QJsonValue 表示值为键 key .
返回的 QJsonValue is QJsonValue::Undefined 若键不存在。
另请参阅 QJsonValue and QJsonValue::isUndefined ().
这是重载函数。
该函数在 Qt 5.7 引入。
返回
true
if
other
is not equal to this object.
赋值 other 到此对象。
返回
true
if
other
is equal to this object.
返回 QJsonValue 表示值为键 key .
This does the same as value ().
返回的 QJsonValue is QJsonValue::Undefined 若键不存在。
另请参阅 value (), QJsonValue ,和 QJsonValue::isUndefined ().
这是重载函数。
该函数在 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.
另请参阅 value ().
这是重载函数。
该函数在 Qt 5.7 引入。