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

QJsonDocument::array() returns a repeatly encapsulated QJsonArray

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 6.2.2
    • Core: Object Model
    • None
    • Fedora Linux 35, GCC 11.2.1
    • Linux/X11

    Description

      I have following codes for parsing a JSON file containing an array:

      QString
      TP_PlaylistWindow::createPlaylistFromJSON( const QJsonDocument &I_jDoc )
      {
          qDebug() << "I_jDoc:" << I_jDoc;
          auto jArray_Root { I_jDoc.array() };
          qDebug() << "jArray_Root:" << jArray_Root;
          ...
      

      The output result is:

      I_jDoc: QJsonDocument([{"fileList":[],"listName":"Default"},{"fileList":[],"listName":"List 2"}])
      jArray_Root: QJsonArray([[{"fileList":[],"listName":"Default"},{"fileList":[],"listName":"List 2"}]])
      

      And you can see that the returned QJsonArray was encapsulated by array brackets [] once again, which was not expected since I need to take off the extra array brackets before interpreting the real array.

      I also observed a similar phenomenon on QJsonValue::toArray(). Is this mechanism intended?

      Attachments

        Issue Links

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

          Activity

            People

              zxfksie Xiang Zhang
              zxfksie Xiang Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes