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

Flaw in QJsonObject makes inserting values from the same object fail

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.13.2, 5.15.0 Beta1, 6.2.0
    • None

    Description

      Copying values in QJsonObjects sometimes doesn't work:

          QJsonObject obj;
          obj["value"] = "TEST";
          obj["prop2"] = obj["value"];
          qDebug() << obj;
      

      Output:

      QJsonObject({"prop2":null,"value":"TEST"})
      

      The problem is that QJsonObject keeps its items sorted lexicographically, so inserting "prop2" makes the QJsonValueRef of obj["value"] point to the newly inserted item.

      Tested with both 5.13.2 (original binary QJsonDocument implementation) and 5.15.0 beta 4 (QCborContainerPrivate implementation).

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes