Q:

How to parse multidimensional JSON array in Qt? 

Suppose i have a JSON file of x-y coordinates like this:
{
"coordinates": [[  [1,2], [3,4], [5,6]  ]]
}

Then how i would parse it in Qt5 with its built in JSON parsing support? 
Just i want to know how i would be able to access those values inside such an array of coordinates? 
Let me share my effort in this respect and see upto what level i have been successful in parsing JSON data. 
#include <QFile>
#include <QByteArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QDebug>

//    sample.json:
//    {
//        "agentsArray": [{
//            "name": "X",
//            "coordinates": [[  [2,2] ]]
//        }, {
//            "name": "Y",
//            "coordinates": [[  [6,6] ]]
//        }]
//    }

    QFile jsonFile("main.json");
    jsonFile.open(QIODevice::ReadOnly | QIODevice::Text);
    QByteArray jsonFileData = jsonFile.readAll();
    jsonFile.close();

    QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonFileData);
    QJsonObject jsonObject = jsonDocument.object();

    QJsonValue agentsArrayValue = jsonObject.value("agentsArray");
    QJsonArray agentsArray = agentsArrayValue.toArray();

    foreach (const QJsonValue & v, agentsArray)
    {
        qDebug() << v.toObject().value("name").toString();

        /* As i want to get the coordinates value but
         * i dont know what to do with this? 
         */
        // qDebug() << v.toObject().value("coordinates").toArray(); // ? 

        qDebug() << "--------------------";
    }

Output is:
"X"
--------------------
"Y"
--------------------

A:

This is how i managed to parse the JSON multidimensional array in Qt5, hope it may help you too;
#include <QFile>
#include <QByteArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QDebug>

//    sample.json:
//    {
//        "agentsArray": [{
//            "name": "X",
//            "coordinates": [[  [2,3] ]]
//        }, {
//            "name": "Y",
//            "coordinates": [[  [6,7] ]]
//        }]
//    }

    QFile jsonFile("main.json");
    jsonFile.open(QIODevice::ReadOnly | QIODevice::Text);
    QByteArray jsonFileData = jsonFile.readAll();
    jsonFile.close();

    QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonFileData);
    QJsonObject jsonObject = jsonDocument.object();

    QJsonValue agentsArrayValue = jsonObject.value("agentsArray");
    QJsonArray agentsArray = agentsArrayValue.toArray();

    foreach (const QJsonValue & v, agentsArray)
    {
        qDebug() << v.toObject().value("name").toString();

        qDebug() <<"Lat: " << v.toObject().value("coordinates").toArray().at(0).toArray().at(0).toArray().at(0).toInt();
        qDebug() <<"Lon: " << v.toObject().value("coordinates").toArray().at(0).toArray().at(0).toArray().at(1).toInt();

        qDebug() << "--------------------";
    }

Output is:
"X"
Lat:  2
Lon:  3
--------------------
"Y"
Lat:  6
Lon:  7
--------------------

