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

QJsonDocument can not parse, If exponent part is upper E and number is 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.9.2
    • 5.9.0
    • Core: Other
    • None
    • 8616b2112c0f24f71892488cefb146ae3505da9e

      For example:

      qDebug() << QJsonDocument::fromJson( "\{\"key\": 0E-1}" ).object();
      qDebug() << QJsonDocument::fromJson( "\{\"key\": 0e-1}" ).object();
      qDebug() << QJsonDocument::fromJson( "\{\"key\": 1E-1}" ).object();
      qDebug() << QJsonDocument::fromJson( "\{\"key\": 1e-1}" ).object();
      

      Output:

      QJsonObject()
      QJsonObject(\{"key":0})
      QJsonObject(\{"key":0.1})
      QJsonObject(\{"key":0.1})
      

      The first example, QJsonDocument after parse can not output the correct results. QJsonDocument is null.

      From Qt document (JSON Support in Qt)
      Qt is to support RFC-4627, and RFC-4627 has said:

      An exponent part begins with the letter E in upper or lowercase, which may be followed by a plus or minus sign. The E and optional sign are followed by one or more digits.

      I also tried some JSON parsing tools, they can be normal analysis: {"key": 0E-1}

      Such as this tool:

      http://tool.oschina.net/codeformat/json

        For Gerrit Dashboard: QTBUG-61350
        # Subject Branch Project Status CR V

            thiago Thiago Macieira
            jasonwong Jason Wong
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes