Unsolved Parsing JSON with Qt
-
Hey i want to parse a JSON.
My JSON looks like:
{ "static": { "readFiles": { "balance": "statisch", "level1": { "int id": 0, "level2": { "typ": "TextField", "background-color": "grey" }, "level1_1": { "int id_1": 0, "level2_1": { "typ": "TextField", "background-color": "grey" } } } } } }
now i want to parse each level.
The JSON-File have always the same structur, only the content can be diffrent and they can be more informations in this file.
I want to get the content from "static" and from "level2" for example.
How can i parse this file ? -
Hi,
The starting point will likely be QJsonDocument.
-
Hey @SGaist thank you for your request,
i now this Documentation, but i dont find something how help me on my question.
-
All described in the documentation of QJsonDocument and examples. I would suggest something like that:
QFile file(filename); file.open(); QJsonDocument json = QJsonDocument::fromJson(file.readAll()); QJsonObject static = json["static"]; QJsonObject readfiles= static ["readFiles"]; ....