aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2022-10-25 11:50:13 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-10-26 07:34:09 +0000
commit9c63de2c52d0779b64634887bb631ec50209fc78 (patch)
tree64ea2806bc9773fab3d94da87ecc2b5f19e698e4 /src/qml
parent31d4bc2a2ff9791963d333c1e88b619fa870a085 (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>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsapi/qjsvalue.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 7d189e3e41..13bf47ce73 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -142,6 +142,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
*/
/*!