Uploaded image for project: 'OASIS Open Data Protocol (OData) TC'
  1. OASIS Open Data Protocol (OData) TC
  2. ODATA-286

Need clarity about JSON encoding of Single and Double (and the applicability or not of ABNF rules) particularly for NaN, INF and -INF

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: V4.0_WD01
    • Fix Version/s: V4.0_WD01
    • Component/s: JSON Format
    • Labels:
      None
    • Environment:

      [Applied]

    • Proposal:
      Hide

      Allow that Single and Double can be represented as JSON number, except for "NaN", "INF" and "-INF" which must be encoded as JSON strings.
      Also clarify use of these string values (from ABNF) in Atom, and include examples in both.

      Show
      Allow that Single and Double can be represented as JSON number, except for "NaN", "INF" and "-INF" which must be encoded as JSON strings. Also clarify use of these string values (from ABNF) in Atom, and include examples in both.
    • Resolution:
      Show
      Accepted: https://www.oasis-open.org/committees/download.php/49055/odata-meeting-35_on-20130502-minutes.html#odata-286

      Description

      According to odata-json-format-v4.0-wd01-2013-03-05-RH.doc (section 4.1.1)

      Values of types Byte, SByte, Int16, Int32, Single, and Double are represented as JSON numbers.

      but that does not account for NaN, Infinity and -Infinity.

      Now the ABNF (odata-abnf-construction-rules-v4.0-wd01.html) states that these values can be encoded as: 'NaN', 'INF' and '-INF'.

      However I understood that the ABNF rules are applicable to values in URLs, not in JSON (unless explicitly stated in the JSON doc, as is the case with geo types).

      Also note that the ABNF allows Double values to end with "d", and Single values to end with "f".

      Here then, we see an apparent contradiction. NaN, INF, -INF, Double values ending with "d", and Single values ending with "f" are permitted by the ABNF rules, but not permitted in a JSON number.

      The JSON spec (http://www.ietf.org/rfc/rfc4627.txt) section 2.4 quite clearly states:

      Numeric values that cannot be represented as sequences of digits
      (such as Infinity and NaN) are not permitted.

        Attachments

          Activity

            People

            • Assignee:
              handl Ralf Handl
              Reporter:
              evan.ireland.2 Evan Ireland
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: