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

QJsonDocument::array() returns a repeatly encapsulated QJsonArray

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Out of scope
    • Affects Version/s: 6.2.2
    • Fix Version/s: None
    • Component/s: Core: Object Model
    • Labels:
      None
    • Environment:
      Fedora Linux 35, GCC 11.2.1
    • Platform/s:
      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

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

          Activity

            People

            Assignee:
            zxfksie Xiang Zhang
            Reporter:
            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