QJsonArrayclass encapsulates a JSON array. 更多 …
def
__add__
(v)
def
__eq__
(other)
def
__iadd__
(v)
def
__lshift__
(v)
def
__ne__
(other)
def
append
(value)
def
at
(i)
def
contains
(element)
def
count
()
def
empty
()
def
first
()
def
insert
(i, value)
def
isEmpty
()
def
last
()
def
operator[]
(i)
def
pop_back
()
def
pop_front
()
def
prepend
(value)
def
push_back
(t)
def
push_front
(t)
def
removeAt
(i)
def
removeFirst
()
def
removeLast
()
def
replace
(i, value)
def
size
()
def
swap
(other)
def
takeAt
(i)
def
toVariantList
()
def
fromStringList
(list)
def
fromVariantList
(list)
A JSON array is a list of values. The list can be manipulated by inserting and removing
QJsonValue‘s from the array.A
QJsonArraycan be converted to and from aQVariantList. You can query the number of entries withsize(),insert(),和removeAt()entries from it and iterate over its content using the standard C++ iterator pattern.
QJsonArrayis 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 JSON 保存游戏范例
QJsonArray
¶
QJsonArray(other)
- param other
Creates an empty array.
PySide2.QtCore.QJsonArray.
append
(
value
)
¶
value
–
QJsonValue
插入
value
at the end of the array.
PySide2.QtCore.QJsonArray.
at
(
i
)
¶
i
–
int
返回
QJsonValue
representing the value for index
i
.
返回的
QJsonValue
is
Undefined
, if
i
is out of bounds.
PySide2.QtCore.QJsonArray.
contains
(
element
)
¶
element
–
QJsonValue
bool
返回
true
if the array contains an occurrence of
value
, otherwise
false
.
另请参阅
PySide2.QtCore.QJsonArray.
empty
(
)
¶
bool
此函数是为兼容 STL 而提供的。它相当于
isEmpty()
并返回
true
if the array is empty.
PySide2.QtCore.QJsonArray.
first
(
)
¶
Returns the first value stored in the array.
如同
at(0)
.
另请参阅
PySide2.QtCore.QJsonArray.
fromStringList
(
list
)
¶
list – 字符串列表
Converts the string list
list
到
QJsonArray
.
The values in
list
will be converted to JSON values.
PySide2.QtCore.QJsonArray.
fromVariantList
(
list
)
¶
list –
Converts the variant list
list
到
QJsonArray
.
QVariant
values in
list
will be converted to JSON values.
PySide2.QtCore.QJsonArray.
insert
(
i
,
value
)
¶
i
–
int
value
–
QJsonValue
PySide2.QtCore.QJsonArray.
isEmpty
(
)
¶
bool
返回
true
if the object is empty. This is the same as
size()
== 0.
另请参阅
PySide2.QtCore.QJsonArray.
last
(
)
¶
Returns the last value stored in the array.
如同
at(size()
-
1)
.
另请参阅
PySide2.QtCore.QJsonArray.
__ne__
(
other
)
¶
other
–
QJsonArray
bool
返回
true
if this array is not equal to
other
.
PySide2.QtCore.QJsonArray.
__add__
(
v
)
¶
v
–
QJsonValue
Returns an array that contains all the items in this array followed by the provided
value
.
另请参阅
operator+=()
PySide2.QtCore.QJsonArray.
__iadd__
(
v
)
¶
v
–
QJsonValue
追加
value
to the array, and returns a reference to the array itself.
另请参阅
append()
operator
PySide2.QtCore.QJsonArray.
__lshift__
(
v
)
¶
v
–
QJsonValue
PySide2.QtCore.QJsonArray.
__eq__
(
other
)
¶
other
–
QJsonArray
bool
返回
true
if this array is equal to
other
.
PySide2.QtCore.QJsonArray.operator[](i)
i
–
int
这是重载函数。
如同
at()
.
PySide2.QtCore.QJsonArray.
pop_back
(
)
¶
此函数是为兼容 STL 而提供的。它相当于
removeLast()
. The array must not be empty. If the array can be empty, call
isEmpty()
在调用此函数之前。
PySide2.QtCore.QJsonArray.
pop_front
(
)
¶
此函数是为兼容 STL 而提供的。它相当于
removeFirst()
. The array must not be empty. If the array can be empty, call
isEmpty()
在调用此函数之前。
PySide2.QtCore.QJsonArray.
prepend
(
value
)
¶
value
–
QJsonValue
插入
value
at the beginning of the array.
这如同
insert(0,
value)
and will prepend
value
to the array.
PySide2.QtCore.QJsonArray.
push_back
(
t
)
¶
t
–
QJsonValue
此函数是为兼容 STL 而提供的。它相当于
append(value)
and will append
value
to the array.
PySide2.QtCore.QJsonArray.
push_front
(
t
)
¶
t
–
QJsonValue
此函数是为兼容 STL 而提供的。它相当于
prepend(value)
and will prepend
value
to the array.
PySide2.QtCore.QJsonArray.
removeAt
(
i
)
¶
i
–
int
Removes the value at index position
i
.
i
must be a valid index position in the array (i.e.,
0
<=
i
<
size()
).
PySide2.QtCore.QJsonArray.
removeFirst
(
)
¶
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()
在调用此函数之前。
另请参阅
PySide2.QtCore.QJsonArray.
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()
在调用此函数之前。
另请参阅
PySide2.QtCore.QJsonArray.
replace
(
i
,
value
)
¶
i
–
int
value
–
QJsonValue
替换项在索引位置
i
with
value
.
i
must be a valid index position in the array (i.e.,
0
<=
i
<
size()
).
另请参阅
operator[]()
removeAt()
PySide2.QtCore.QJsonArray.
size
(
)
¶
int
Returns the number of values stored in the array.
PySide2.QtCore.QJsonArray.
swap
(
other
)
¶
other
–
QJsonArray
Swaps the array
other
with this. This operation is very fast and never fails.
PySide2.QtCore.QJsonArray.
takeAt
(
i
)
¶
i
–
int
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()
).
If you don’t use the return value,
removeAt()
is more efficient.
另请参阅
PySide2.QtCore.QJsonArray.
toVariantList
(
)
¶
把此对象转换成
QVariantList
.
返回创建的映射。