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

bad QJsonArray constructor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.13.2, 5.14.0 Beta2
    • Core: Other
    • None
    • Linux/Wayland, Linux/X11, Linux/Other display system, macOS

    Description

      The following code produces different results on Linux and macOS:

      #include <QDebug>
      #include <QJsonArray>
      #include <QJsonDocument>
      #include <QJsonObject>
      
      int main()
      {
          QJsonDocument doc = QJsonDocument::fromJson("{ \"rooms\": [ 1 ] }");
          QJsonObject obj = doc.object();
          // macOS: QJsonArray([1])
          // linux: QJsonArray([[1]])
          qDebug() << QJsonArray { obj["rooms"].toArray() };
          // both macOS and Linux: QJsonArray([1])
          qDebug() << QJsonArray (obj["rooms"].toArray() );
          return 0;
      }
      

      As in the comments, on Linux, the first constructor form for QJsonArray produces [[1]], while on macOS it produces [1]. In my opinion, the correct behaviour is the one from macOS.

      Nevertheless, even if you consider the correct behaviour to be the one on Linux (aka return [[1]] for the first constructor form), the same array should be returned on both macOS and Linux.

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            iborco Ionutz Borcoman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes