Parsing JSON in QML is no different from parsing JSON in Javascript , because QML provides an ECMAScript-based environment ( link ) with some changes, especially for QML.
So you can use the built-in JSON.parse() function. The following example is possible in QML:
import QtQuick 2.7 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Component.onCompleted: { var JsonString = '{"a":"A whatever, run","b":"B fore something happens"}'; var JsonObject= JSON.parse(JsonString);
And for that very reason, the Qt docs don't say anything about this particular function:
The standard ECMAScript built-in modules are not explicitly documented in the QML documentation. For more information about their use, please refer to the ECMA-262 5th edition standard or one of the many interactive JavaScript links and tutorials, such as the W3Schools JavaScript link (link to JavaScript objects)
A source
source share