QJsonArray¶
The QJsonArray
class encapsulates a JSON array. More…
Synopsis¶
Functions¶
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
()
Static functions¶
def
fromStringList
(list)def
fromVariantList
(list)
Detailed Description¶
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()
, and 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
.
See also
- class PySide6.QtCore.QJsonArray¶
PySide6.QtCore.QJsonArray(other)
- Parameters
other –
PySide6.QtCore.QJsonArray
Creates an empty array.
- PySide6.QtCore.QJsonArray.append(value)¶
- Parameters
value –
PySide6.QtCore.QJsonValue
Inserts value
at the end of the array.
- PySide6.QtCore.QJsonArray.at(i)¶
- Parameters
i –
qsizetype
- Return type
Returns a QJsonValue
representing the value for index i
.
The returned QJsonValue
is Undefined
, if i
is out of bounds.
- PySide6.QtCore.QJsonArray.contains(element)¶
- Parameters
element –
PySide6.QtCore.QJsonValue
- Return type
bool
Returns true
if the array contains an occurrence of value
, otherwise false
.
See also
- PySide6.QtCore.QJsonArray.count()¶
- Return type
qsizetype
Same as size()
.
See also
- PySide6.QtCore.QJsonArray.empty()¶
- Return type
bool
This function is provided for STL compatibility. It is equivalent to isEmpty()
and returns true
if the array is empty.
- PySide6.QtCore.QJsonArray.first()¶
- Return type
Returns the first value stored in the array.
Same as at(0)
.
See also
- static PySide6.QtCore.QJsonArray.fromStringList(list)¶
- Parameters
list – list of strings
- Return type
Converts the string list list
to a QJsonArray
.
The values in list
will be converted to JSON values.
See also
- static PySide6.QtCore.QJsonArray.fromVariantList(list)¶
- Parameters
list –
- Return type
Converts the variant list list
to a QJsonArray
.
The QVariant
values in list
will be converted to JSON values.
Note
Conversion from QVariant
is not completely lossless. Please see the documentation in fromVariant()
for more information.
See also
- PySide6.QtCore.QJsonArray.insert(i, value)¶
- Parameters
i –
qsizetype
value –
PySide6.QtCore.QJsonValue
Inserts 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.
See also
- PySide6.QtCore.QJsonArray.isEmpty()¶
- Return type
bool
Returns true
if the object is empty. This is the same as size()
== 0.
See also
- PySide6.QtCore.QJsonArray.last()¶
- Return type
Returns the last value stored in the array.
Same as at(size() - 1)
.
See also
- PySide6.QtCore.QJsonArray.__ne__(other)¶
- Parameters
other –
PySide6.QtCore.QJsonArray
- Return type
bool
Returns true
if this array is not equal to other
.
- PySide6.QtCore.QJsonArray.__add__(v)¶
- Parameters
- Return type
Returns an array that contains all the items in this array followed by the provided value
.
See also
operator+=()
- PySide6.QtCore.QJsonArray.__iadd__(v)¶
- Parameters
- Return type
Appends value
to the array, and returns a reference to the array itself.
See also
append()
operator
- PySide6.QtCore.QJsonArray.__lshift__(v)¶
- Parameters
- Return type
- PySide6.QtCore.QJsonArray.__eq__(other)¶
- Parameters
other –
PySide6.QtCore.QJsonArray
- Return type
bool
Returns true
if this array is equal to other
.
- PySide6.QtCore.QJsonArray.operator[](i)
- Parameters
i –
qsizetype
- Return type
This is an overloaded function.
Same as at()
.
- PySide6.QtCore.QJsonArray.pop_back()¶
This function is provided for STL compatibility. It is equivalent to removeLast()
. The array must not be empty. If the array can be empty, call isEmpty()
before calling this function.
- PySide6.QtCore.QJsonArray.pop_front()¶
This function is provided for STL compatibility. It is equivalent to removeFirst()
. The array must not be empty. If the array can be empty, call isEmpty()
before calling this function.
- PySide6.QtCore.QJsonArray.prepend(value)¶
- Parameters
value –
PySide6.QtCore.QJsonValue
Inserts value
at the beginning of the array.
This is the same as insert(0, value)
and will prepend value
to the array.
- PySide6.QtCore.QJsonArray.push_back(t)¶
- Parameters
This function is provided for STL compatibility. It is equivalent to append(value)
and will append value
to the array.
- PySide6.QtCore.QJsonArray.push_front(t)¶
- Parameters
This function is provided for STL compatibility. It is equivalent to prepend(value)
and will prepend value
to the array.
- PySide6.QtCore.QJsonArray.removeAt(i)¶
- Parameters
i –
qsizetype
Removes the value at index position i
. i
must be a valid index position in the array (i.e., 0 <= i < size()
).
- PySide6.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()
before calling this function.
See also
- PySide6.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()
before calling this function.
See also
- PySide6.QtCore.QJsonArray.replace(i, value)¶
- Parameters
i –
qsizetype
value –
PySide6.QtCore.QJsonValue
Replaces the item at index position i
with value
. i
must be a valid index position in the array (i.e., 0 <= i < size()
).
See also
operator[]()
removeAt()
- PySide6.QtCore.QJsonArray.size()¶
- Return type
qsizetype
Returns the number of values stored in the array.
- PySide6.QtCore.QJsonArray.swap(other)¶
- Parameters
other –
PySide6.QtCore.QJsonArray
Swaps the array other
with this. This operation is very fast and never fails.
- PySide6.QtCore.QJsonArray.takeAt(i)¶
- Parameters
i –
qsizetype
- Return type
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.
See also
- PySide6.QtCore.QJsonArray.toVariantList()¶
- Return type
Converts this object to a QVariantList.
Returns the created map.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.