QJsonDocument auto sorting



  • 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.


  • Moderators

    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.



  • Ok. That's more or less what I thought. Thank you very much!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.