diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2022-10-25 11:50:13 +0800 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-10-27 08:07:04 +0000 |
commit | f579e668681fddd21a3d74a2fbe68f7a73eadfde (patch) | |
tree | e07d8930470dab9588ce1009b60a768680fe413b | |
parent | 4a466c748133ec819b6afe10f27e7afb8839f39e (diff) |
Doc: add section to QJSValue about converting to JSON
This is especially useful if you already have serialization code that
can perform strict checks on the data, rather than having to rewrite it
to work with QJSValue.
Change-Id: I5b12aa9806e187586ac1b41995633a46621f76c9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 3ed1304ded8aab93df6bebe5a938c3470725a49c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index 388cc1a21a..8370a92ea7 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -106,6 +106,16 @@ integers.append(jsArray.property(i).toInt()); } \endcode + + \section2 Converting to JSON + + It's possible to convert a QJSValue to a JSON type. For example, + to convert to an array, use \l QJSEngine::fromScriptValue(): + + \code + const QJsonValue jsonValue = engine.fromScriptValue<QJsonValue>(jsValue); + const QJsonArray jsonArray = jsonValue.toArray(); + \endcode */ /*! |