QJsonArray 类封装 JSON 数组。 更多...
头: | #include <QJsonArray> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
注意: 此类的所有函数 可重入 .
class | const_iterator |
class | iterator |
ConstIterator | |
Iterator | |
const_pointer | |
const_reference | |
difference_type | |
pointer | |
reference | |
size_type | |
value_type |
QJsonArray () | |
QJsonArray (std::initializer_list<QJsonValue> args ) | |
QJsonArray (const QJsonArray & other ) | |
QJsonArray (QJsonArray && other ) | |
~QJsonArray () | |
void | append (const QJsonValue & value ) |
QJsonValue | at (qsizetype i ) const |
QJsonArray::iterator | begin () |
QJsonArray::const_iterator | begin () const |
QJsonArray::const_iterator | cbegin () const |
QJsonArray::const_iterator | cend () const |
QJsonArray::const_iterator | constBegin () const |
QJsonArray::const_iterator | constEnd () const |
bool | contains (const QJsonValue & value ) const |
qsizetype | count () const |
bool | empty () const |
QJsonArray::iterator | end () |
QJsonArray::const_iterator | end () const |
QJsonArray::iterator | erase (QJsonArray::iterator it ) |
QJsonValue | first () const |
void | insert (qsizetype i , const QJsonValue & value ) |
QJsonArray::iterator | insert (QJsonArray::iterator before , const QJsonValue & value ) |
bool | isEmpty () const |
QJsonValue | last () const |
void | pop_back () |
void | pop_front () |
void | prepend (const QJsonValue & value ) |
void | push_back (const QJsonValue & value ) |
void | push_front (const QJsonValue & value ) |
void | removeAt (qsizetype i ) |
void | removeFirst () |
void | removeLast () |
void | replace (qsizetype i , const QJsonValue & value ) |
qsizetype | size () const |
void | swap (QJsonArray & other ) |
QJsonValue | takeAt (qsizetype i ) |
QVariantList | toVariantList () const |
bool | operator!= (const QJsonArray & other ) const |
QJsonArray | operator+ (const QJsonValue & value ) const |
QJsonArray & | operator+= (const QJsonValue & value ) |
QJsonArray & | operator<< (const QJsonValue & value ) |
QJsonArray & | operator= (const QJsonArray & other ) |
QJsonArray & | operator= (QJsonArray && other ) |
bool | operator== (const QJsonArray & other ) const |
QJsonValueRef | operator[] (qsizetype i ) |
QJsonValue | operator[] (qsizetype i ) const |
QJsonArray | fromStringList (const QStringList & list ) |
QJsonArray | fromVariantList (const QVariantList & list ) |
A JSON array is a list of values. The list can be manipulated by inserting and removing QJsonValue 's from the array.
A QJsonArray can be converted to and from a QVariantList. You can query the number of entries with size (), insert (),和 removeAt () entries from it and iterate over its content using the standard C++ iterator pattern.
QJsonArray 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 array to and from text based JSON through QJsonDocument .
另请参阅 在 Qt 中支持 JSON and JSON 保存游戏范例 .
Qt 样式同义词 QJsonArray::const_iterator .
Qt 样式同义词 QJsonArray::iterator .
Typedef for const QJsonValue *. Provided for STL compatibility.
Typedef for const QJsonValue &. Provided for STL compatibility.
Typedef for qsizetype. Provided for STL compatibility.
typedef 对于 QJsonValue *. Provided for STL compatibility.
typedef 对于 QJsonValue &. Provided for STL compatibility.
Typedef for qsizetype. Provided for STL compatibility.
typedef 对于 QJsonValue . Provided for STL compatibility.
Creates an empty array.
Creates an array initialized from args initialization list.
QJsonArray can be constructed in a way similar to JSON notation, for example:
QJsonArray array = { 1, 2.2, QString() };
创建副本为 other .
Since QJsonArray is implicitly shared, the copy is shallow as long as the object doesn't get modified.
Move-constructs a QJsonArray from other .
Deletes the array.
插入 value at the end of the array.
返回 QJsonValue representing the value for index i .
返回的
QJsonValue
is
Undefined
,若
i
is out of bounds.
返回 STL 样式迭代器 pointing to the first item in the array.
另请参阅 constBegin () 和 end ().
这是重载函数。
返回常量 STL 样式迭代器 pointing to the first item in the array.
返回常量 STL 样式迭代器 pointing to the imaginary item after the last item in the array.
返回常量 STL 样式迭代器 pointing to the first item in the array.
返回常量 STL 样式迭代器 pointing to the imaginary item after the last item in the array.
另请参阅 constBegin () 和 end ().
返回
true
if the array contains an occurrence of
value
, otherwise
false
.
另请参阅 count ().
如同 size ().
另请参阅 size ().
此函数为兼容 STL (标准模板库) 提供。它相当于
isEmpty
() 并返回
true
if the array is empty.
返回 STL 样式迭代器 pointing to the imaginary item after the last item in the array.
这是重载函数。
Removes the item pointed to by it , and returns an iterator pointing to the next item.
另请参阅 removeAt ().
Returns the first value stored in the array.
如同
at(0)
.
另请参阅 at ().
[static]
QJsonArray
QJsonArray::
fromStringList
(const
QStringList
&
list
)
Converts the string list list 到 QJsonArray .
The values in list will be converted to JSON values.
另请参阅 toVariantList () 和 QJsonValue::fromVariant ().
[static]
QJsonArray
QJsonArray::
fromVariantList
(const
QVariantList
&
list
)
Converts the variant list list 到 QJsonArray .
The QVariant values in list will be converted to JSON values.
注意: Conversion from QVariant is not completely lossless. Please see the documentation in QJsonValue::fromVariant () 了解更多信息。
另请参阅 toVariantList () 和 QJsonValue::fromVariant ().
插入
value
at index position
i
in the array. If
i
is
0
, the value is prepended to the array. If
i
is
size
(), the value is appended to the array.
另请参阅 append (), prepend (), replace (),和 removeAt ().
插入 value before the position pointed to by before , and returns an iterator pointing to the newly inserted item.
返回
true
if the object is empty. This is the same as
size
() == 0.
另请参阅 size ().
Returns the last value stored in the array.
如同
at(size() - 1)
.
另请参阅 at ().
此函数为兼容 STL (标准模板库) 提供。它相当于 removeLast (). The array must not be empty. If the array can be empty, call isEmpty () before calling this function.
此函数为兼容 STL (标准模板库) 提供。它相当于 removeFirst (). The array must not be empty. If the array can be empty, call isEmpty () before calling this function.
插入 value at the beginning of the array.
这如同
insert(0, value)
and will prepend
value
to the array.
此函数为兼容 STL (标准模板库) 提供。它相当于 append (value) and will append value to the array.
此函数为兼容 STL (标准模板库) 提供。它相当于 prepend (value) and will prepend value to the array.
Removes the value at index position
i
.
i
must be a valid index position in the array (i.e.,
0 <= i < size()
).
Removes the first item in the array. Calling this function is equivalent to calling
removeAt(0)
. The array must not be empty. If the array can be empty, call
isEmpty
() before calling this function.
另请参阅 removeAt () 和 removeLast ().
Removes the last item in the array. Calling this function is equivalent to calling
removeAt(size() - 1)
. The array must not be empty. If the array can be empty, call
isEmpty
() before calling this function.
另请参阅 removeAt () 和 removeFirst ().
替换项在索引位置
i
with
value
.
i
must be a valid index position in the array (i.e.,
0 <= i < size()
).
另请参阅 operator[] () 和 removeAt ().
Returns the number of values stored in the array.
Swaps the array other with this. This operation is very fast and never fails.
Removes the item at index position
i
and returns it.
i
must be a valid index position in the array (i.e.,
0 <= i < size()
).
若不使用返回值, removeAt () 效率更高。
另请参阅 removeAt ().
Converts this object to a QVariantList.
返回创建的映射。
返回
true
if this array is not equal to
other
.
Returns an array that contains all the items in this array followed by the provided value .
另请参阅 operator+= ().
追加 value to the array, and returns a reference to the array itself.
另请参阅 append () 和 operator<< ().
追加 value to the array, and returns a reference to the array itself.
另请参阅 operator+= () 和 append ().
赋值 other 到此数组。
移动赋值 other 到此数组。
返回
true
if this array is equal to
other
.
Returns the value at index position
i
作为可修改引用。
i
must be a valid index position in the array (i.e.,
0 <= i < size()
).
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 character in the QJsonArray of QJsonObject from which you got the reference.
另请参阅 at ().
这是重载函数。
如同 at ().