QtHarmony Namespace
The QtHarmony namespace holds free functions of the HarmonyOS platform API. More...
| Header: | #include <qharmonyjsonconversions.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core)target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
Functions
| QJsonObject | mapJsObjectToQJsonObject(int env, int jsObject) |
| int | mapQJsonObjectToJsObject(int env, const QJsonObject &jsonObject) |
Detailed Description
The functions are meant for code running on the JS thread, where the platform APIs are usable.
See also Qt for HarmonyOS Platform API.
Function Documentation
QJsonObject QtHarmony::mapJsObjectToQJsonObject(int env, int jsObject)
Returns the enumerable properties of the JS object jsObject in env as a QJsonObject. Booleans, numbers and strings become JSON values of the same kind, nested objects and arrays become JSON objects and arrays, and JS null becomes JSON null. Property values with no JSON counterpart (undefined, functions, symbols, BigInt) are skipped in objects and become null in arrays. Returns an empty QJsonObject if jsObject is not a JS object (nullptr, null, undefined, a primitive) or is an array or a function. It also returns an empty QJsonObject, logging the error and leaving no exception pending, if jsObject is nested too deeply, for example because it contains a reference cycle, or if a JS exception is raised while reading it, for example by a property getter.
This is how a platform object, for example a received Want, is taken to the Qt thread.
int QtHarmony::mapQJsonObjectToJsObject(int env, const QJsonObject &jsonObject)
Returns a new JS object in env with the properties of jsonObject, for use on the JS thread. Nested objects and arrays become JS objects and arrays; JSON null becomes JS null. Returns nullptr, logging the error and leaving no exception pending, if a JS exception is raised during the mapping.
This is how a request object, for example a Want, is built for a platform API call from Qt data.
© 2026 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.