← Prev in month ← Prev in thread

[OASIS Issue Tracker] (ODATA-707) 4.5.3: Type inference for numeric values doesn't work with JSON.parse()

From
OASIS Issues Tracker <>
Date
2014-06-24T09:12:32+00:00
ID
Thread
[OASIS Issue Tracker] (ODATA-707) 4.5.3: Type inference for numeric values doesn't work with JSON.parse()
Ralf Handl created ODATA-707:
--------------------------------

             Summary: 4.5.3: Type inference for numeric values doesn't work with JSON.parse()
                 Key: ODATA-707
                 URL: https://issues.oasis-open.org/browse/ODATA-707
             Project: OASIS Open Data Protocol (OData) TC
          Issue Type: Bug
          Components: OData JSON Format
    Affects Versions: V4.0_OS
            Reporter: Ralf Handl
             Fix For: V4.0_ERRATA01


Section 4.5.3 says 

Numeric values have a first-class representation in JSON and do not need any additional annotations. If the value of a property is represented as a number without a dot (.), e or E embedded, the type should be interpreted as an integer value, otherwise as a decimal, double, or single value.

Unfortunately this type inference does not work for clients using generic JSON parsers, e.g. JSON.parse() in JavaScript. The lines

var payload = '{ "x" : 1.2e4 }';
var parsed = JSON.parse(payload);
console.log(parsed.x);

will result in 12000.





--
This message was sent by Atlassian JIRA
(v6.2.2#6258)
← Prev in month ← Prev in thread