Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85535

How to avoid automatic sorting by name when saving JSON files with QJsonObject

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.15.0 RC2
    • Core: Object Model
    • None
    • All
    • What I need to do is to read the A.json file,modify some case, and then store it in a new file of the same format, which is now saved as b.json file . Obviously, this is not satisfactory. Is there any way I can save it in the format of a.json file?

    Description

      How to avoid automatic sorting by name when saving JSON files with QJsonObject?

      for example:

      void SaveJson()
      {
      QJsonObject sub;
      sub.insert("serial",QJsonValue(serial));
      sub.insert("name",QJsonValue(name));
      obj.insert("server",QJsonValue(sub));

       

      {{}}

      QJsonDocument doc(sub);

      QByteArray data=doc.toJson();

      {{ QFile file("D:
      test1.json");}}

      {{ file.open(QIODevice::WriteOnly);}}

      {{ file.write(data);}}

      {{ file.close();}}

      }

      The result will be "name serial server".How can I avoid automatic sorting by name?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            redas redas gu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes