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

Inconsistent conversion of integer values from JSON to QVariant

    XMLWordPrintable

    Details

    • Commits:
      3579a91f83deeef6d747ffb8971fce287bc7edc5 (qt/qtbase/5.15)

      Description

      The conversion of integer values from a JSON document to a QVariant has changed from 5.14.2 to 5.15.0. It can happen that an integer value in the JSON document is converted to a QVariant of type qlonglong instead of double, depending on whether the value is contained in braces (and therefore part of a QMap in the converted result) or not. In 5.14.2, it will consistently be converted to a QVariant of type double, which is the expected result since the only numeric type for QJsonValue is QJsonValue::Double.
      The attached test project shows the problem, the integer value is converted to different types in 5.15.0 depending on the context, but always to double when the project is started in 5.14.2

      The change converting integer values to qlonglong instead of double seems to be introduced when reimplementing JSON support on top of CBOR (https://codereview.qt-project.org/c/qt/qtbase/+/265312), and https://codereview.qt-project.org/c/qt/qtbase/+/277622 fixes the problem with inconsistency

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              thiago Thiago Macieira
              Reporter:
              shmittal Shveta Mittal
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes