user8183713
user8183713

Reputation:

How to parse QJson file without sorting?

I am parsing a Json file in my Qt application. When I iterate through the QJsonObject keys they are sorted automatically. How can I disable it?

Jsonfile:

{
    "General": [{
            "Address": "TODO",
        }
    ],
    "Coordinates": [{
            "Address": "TODO",
        }   
    ]
}

Code:

QJsonDocument doc = QJsonDocument::fromJson(data.toUtf8());
for (auto& cat : object.keys()) {
}

In the for loop the first object I get is Coordinates, but I want to have in the same order as mentioned in the json file.

Upvotes: 1

Views: 1434

Answers (1)

JuanDeLosMuertos
JuanDeLosMuertos

Reputation: 4620

You cannot disable it, Qt sorts the keys alphabetically and there is not way to change it.

Upvotes: 2

Related Questions