0

Given unnamed JSON document:

[
    {
    },
    {
    },
 ]

Qt 5.10+ has operator[] for QJsonDocument, so we can address any of them by index:

json_doc[1];

How does one do the same in older versions of Qt?

1 Answers1

1

In your particular example the Json document is represented by a Json array. You might get it like:

if (document.isArray() {
    auto a = document.array();
    // TODO: check the array size before
    auto v = a[0];
}
vahancho
  • 20,808
  • 3
  • 47
  • 55