Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to prevent the QJSONObject to sort by the keys?
Qt 6.11 is out! See what's new in the release blog

how to prevent the QJSONObject to sort by the keys?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 719 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    When i insert into the key ,values by using the QJSONObject.
    It always sorted by the keys.and after inserting the keys and values,I dont konw the pre order before inserted the OJSONObject.
    Is there a data object to do that?

    jsulmJ JonBJ 2 Replies Last reply
    0
    • nicker playerN nicker player

      When i insert into the key ,values by using the QJSONObject.
      It always sorted by the keys.and after inserting the keys and values,I dont konw the pre order before inserted the OJSONObject.
      Is there a data object to do that?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @nicker-player JSON does not specify any specific order for the objects. If you really need that you will need to implement that by yourself.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • nicker playerN nicker player

        When i insert into the key ,values by using the QJSONObject.
        It always sorted by the keys.and after inserting the keys and values,I dont konw the pre order before inserted the OJSONObject.
        Is there a data object to do that?

        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #3

        @nicker-player
        As @jsulm says. The order is undefined and that is how Qt QJson... sorts output. If you search this forum there have been several long discussions about this a while ago. One of them elected to use some third-party library to do their desired JSON output sorting. I cannot recall what that was, whether it was Python, whether it's available to you....

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved