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

QJsonArray containing a single QJsonArray has improper behavior

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.10.0
    • Core: Other
    • None
    • Qt 5.10.0, MSVC 2017 x64, Windows 10 x64

      If a QJsonArray contains another QJsonArray, we should expect that the only element within the outermost array is an empty array. However, this is not the case. The value within the outermost array seems to be an undefined QJsonValue. Meanwhile, if the outermost QJsonArray contains multiple items, all items within the outermost array are treated (correctly) as arrays.

      #include <QDebug>
      #include <QJsonArray>
      
      int main(int argc, char *argv[])
      {
          QJsonArray arr({QJsonArray()});
          QJsonArray arr2({QJsonArray(), QJsonArray()});
          qDebug() << arr.first(); // We get QJsonValue(undefined)
          qDebug() << arr.first().isArray(); // false
          qDebug() << arr2.first(); // We get the expected QJsonValue(array, QJsonArray([]))
          qDebug() << arr2.first().isArray(); // true
      

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

            thiago Thiago Macieira
            seth.raymond Seth Raymond
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes