内容表

上一话题

QItemSelectionRange

下一话题

QJsonDocument

QJsonArray

QJsonArray class encapsulates a JSON array. 更多

Inheritance diagram of PySide2.QtCore.QJsonArray

概要

函数

静态函数

详细描述

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 JSON 保存游戏范例

class QJsonArray

QJsonArray(other)

param other

QJsonArray

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

返回 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 .

另请参阅

count()

PySide2.QtCore.QJsonArray. count ( )
返回类型

int

如同 size() .

另请参阅

size()

PySide2.QtCore.QJsonArray. empty ( )
返回类型

bool

此函数是为兼容 STL 而提供的。它相当于 isEmpty() 并返回 true if the array is empty.

PySide2.QtCore.QJsonArray. first ( )
返回类型

QJsonValue

Returns the first value stored in the array.

如同 at(0) .

另请参阅

at()

static PySide2.QtCore.QJsonArray. fromStringList ( list )
参数

list – 字符串列表

返回类型

QJsonArray

Converts the string list list QJsonArray .

The values in list will be converted to JSON values.

static PySide2.QtCore.QJsonArray. fromVariantList ( list )
参数

list

返回类型

QJsonArray

Converts the variant list list QJsonArray .

QVariant values in list will be converted to JSON values.

PySide2.QtCore.QJsonArray. insert ( i , value )
参数
PySide2.QtCore.QJsonArray. isEmpty ( )
返回类型

bool

返回 true if the object is empty. This is the same as size() == 0.

另请参阅

size()

PySide2.QtCore.QJsonArray. last ( )
返回类型

QJsonValue

Returns the last value stored in the array.

如同 at(size() - 1) .

另请参阅

at()

PySide2.QtCore.QJsonArray. __ne__ ( other )
参数

other QJsonArray

返回类型

bool

返回 true if this array is not equal to other .

PySide2.QtCore.QJsonArray. __add__ ( v )
参数

v QJsonValue

返回类型

QJsonArray

Returns an array that contains all the items in this array followed by the provided value .

另请参阅

operator+=()

PySide2.QtCore.QJsonArray. __iadd__ ( v )
参数

v QJsonValue

返回类型

QJsonArray

追加 value to the array, and returns a reference to the array itself.

另请参阅

append() operator

PySide2.QtCore.QJsonArray. __lshift__ ( v )
参数

v QJsonValue

返回类型

QJsonArray

PySide2.QtCore.QJsonArray. __eq__ ( other )
参数

other QJsonArray

返回类型

bool

返回 true if this array is equal to other .

PySide2.QtCore.QJsonArray.operator[](i)
参数

i int

返回类型

QJsonValue

这是重载函数。

如同 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 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

返回类型

QJsonValue

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.

另请参阅

removeAt()

PySide2.QtCore.QJsonArray. toVariantList ( )
返回类型

把此对象转换成 QVariantList .

返回创建的映射。