W3C home > Mailing lists > Public > public-rdf-wg@w3.org > July 2013

What are JSON numbers; was Re: Updated JSON-LD spec to more closely align w/ RDF data model

From: Sandro Hawke <sandro@w3.org>
Date: Tue, 09 Jul 2013 21:41:58 -0400
Message-ID: <51DCBBE6.8070704@w3.org>
To: "Peter F. Patel-Schneider" <pfpschneider@gmail.com>
CC: Markus Lanthaler <markus.lanthaler@gmx.net>, 'RDF WG' <public-rdf-wg@w3.org>
On 07/09/2013 08:36 PM, Peter F. Patel-Schneider wrote:
> I've been looking through the IETF JSON mailing list, and haven't been 
> finding anything about mixed JSON numbers (i.e., some JSON numbers are 
> integers and some are floats).
>
> I would appreciate pointers that support this interpretation of what 
> JSON numbers mean.

Just to be on the safe side, maybe we can ask that group to see if they 
have consensus on some test cases for us.

Presumably every conformant JSON parser produces the same parser-output 
when parsing '{"test1":1}' as it does when parsing ' {"test1": 1}' 
(which has a space after the colon).   This is a test of whether 
whitespace is significant after the colon; presumably it is not.

Here are some more tests about differences that might or might not be 
required to be significant:

Is the the parser-output required to be the same for each of these two 
lines:

Test 1 -- one vs two zeros after the decimal

    {"test1":1.0}
    {"test1":1.00}

Test 2 -- zero vs one zeros after the decimal

    {"test2":1}
    {"test2":1.0}

Test 3 -- a difference too small to be represented in the mantissa of an 
IEEE double

    {"test3":1.0000000000000000}
    {"test3":1.0000000000000001}

Test 4 -- a difference which CAN be represented in IEEE double

    {"test4":1.0000000000000001}
    {"test4":1.0000000000000002}

Firefox and Node both produce the same results for tests 1-3 and a 
different results for test 4, in keeping with what we'd expect from 
JavaScript's use of Double for every number.

Also, is this is valid JSON?   (The exponent is too big for Double)

    {"test5":1e309}

Firefox and Node both treat this as if it said {"test5":null}

I think Markus is saying the JSON spec will be non-constraining on all 
these points, effectively saying a conformant JSON parser MAY produce 
different output from the two lines even in test1.

       -- Sandro
Received on Wednesday, 10 July 2013 01:42:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:04:30 UTC