Qt 6.11 is out! See what's new in the release
blog
QJsonDocument auto sorting
General and Desktop
3
Posts
2
Posters
3.0k
Views
1
Watching
-
Hi,
I'm loading some data from a JSON file to a QJsonDocument, editing, and writing back to file. I see that QJsonDocument automatically sorts objects alphabetically. So when I write to file, everything is sorted in that order, which I would like not happen. Is there a way to avoid this?
Cheers.
-
AFAIK you can't. A JSON object is an unordered set of name-value pairs. This means that the order is implementation specific. In case of Qt this is probably (I haven't checked) a QMap, which holds its data in sorted-by-key order.