QJsonDocument

PyQt5.QtCore.QJsonDocument

Description

The QJsonDocument class provides a way to read and write JSON documents.

QJsonDocument is a class that wraps a complete JSON document and can read and write this document both from a UTF-8 encoded text based representation as well as Qt’s own binary format.

A JSON document can be converted from its text-based representation to a QJsonDocument using QJsonDocument::fromJson(). toJson() converts it back to text. The parser is very fast and efficient and converts the JSON to the binary representation used by Qt.

Validity of the parsed document can be queried with !isNull()

A document can be queried as to whether it contains an array or an object using isArray() and isObject(). The array or object contained in the document can be retrieved using array() or object() and then read or manipulated.

A document can also be created from a stored binary representation using fromBinaryData() or fromRawData().

Enums

DataValidation

TODO

Member

Value

Description

BypassValidation

TODO

TODO

Validate

TODO

TODO


JsonFormat

This value defines the format of the JSON byte array produced when converting to a QJsonDocument using toJson().

Member

Value

Description

Compact

1

Defines a compact output as follows:

#     {"Array":[true,999,"string"],"Key":"Value","null":null}
Indented

0

Defines human readable output as follows:

#     {
#         "Array": [
#             true,
#             999,
#             "string"
#         ],
#         "Key": "Value",
#         "null": null
#     }

Methods

__init__()

TODO


__init__(Dict[str, Union[QJsonValue, Type, Iterable[QJsonValue], bool, int, float, str]])

TODO


__init__(Iterable[QJsonValue])

TODO


__init__(QJsonDocument)

TODO


array() → List[QJsonValue]

See also

setArray().


__eq__(QJsonDocument) → bool

TODO


@staticmethod
fromBinaryData(Union[QByteArray, bytes, bytearray], validation: DataValidation = Validate) → QJsonDocument

TODO


@staticmethod
fromJson(Union[QByteArray, bytes, bytearray], error: QJsonParseError = None) → QJsonDocument

TODO


@staticmethod
fromRawData(str, int, validation: DataValidation = Validate) → QJsonDocument

TODO


@staticmethod
fromVariant(Any) → QJsonDocument

TODO


__getitem__(str) → QJsonValue

TODO


__getitem__(int) → QJsonValue

TODO


isArray() → bool

TODO


isEmpty() → bool

TODO


isNull() → bool

TODO


isObject() → bool

TODO


__ne__(QJsonDocument) → bool

TODO


object() → Dict[str, Union[QJsonValue, Type, Iterable[QJsonValue], bool, int, float, str]]

See also

setObject().


rawData() → (str, int)

TODO


setArray(Iterable[QJsonValue])

See also

array().


setObject(Dict[str, Union[QJsonValue, Type, Iterable[QJsonValue], bool, int, float, str]])

TODO


swap(QJsonDocument)

TODO


toBinaryData() → QByteArray

TODO


toJson() → QByteArray

TODO


toJson(JsonFormat) → QByteArray

TODO


toVariant() → Any

TODO