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

QJsonValue::toVariant() result type doesn't match expectation for some numeric input

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P1: Critical
    • None
    • 6.0.0 Alpha
    • Core: Other
    • None
    • All

    Description

      I noticed a change in behaviour while attempting to fix QtPIM unit tests to pass when built with Qt6.  The following example shows the issue: I would expect a value "2.0" to be parsed as a double rather than an integral type.

      #include <QCoreApplication>
      #include <QString>
      #include <QJsonDocument>
      #include <QJsonArray>
      #include <QJsonValue>
      #include <QtDebug>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
          // with Qt5 this produces QVariant(double, 2)
          // with Qt6 this produces QVariant(qlonglong, 2)
          qWarning() << QJsonDocument::fromJson(QStringLiteral("[ 2.0 ]").toUtf8()).array().at(0).toVariant();
          return 0;
      }
      

      This might be somehow related to the QTBUG-28560 changes although I'm not certain.

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            chrisadams Christopher Adams
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes