Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt JSON access to elements value
kiwimess last edited by
I have been exploring to parse JSON in Qt. I need to access to only few values in quite large JSON data file. In PHP there is a path like this @$json['data']['Rows'][$i]['Columns']['Value']@ to get access straight to elements value. In Qt do I really have to parse every level of JSON array via QVariantMap to find deep level values?
andre last edited by
You don't need to go through QVariantMap, but API not all that fantastic either. See QJsonObject, QJsonValue, and QJsonArray for details.
However, you're not bound to only use Qt itself of course. Any C++ library will do really. So, perhaps you could look into "this":https://github.com/nlohmann/json as it seems to support a syntax very much like what you use in PHP.