Re: Updated JSON-LD spec to more closely align w/ RDF data model

On 07/09/2013 02:00 AM, Markus Lanthaler wrote:
> On Tuesday, July 09, 2013 12:00 AM, Peter F. Patel-Schneider wrote:
>> On 07/08/2013 12:13 PM, Markus Lanthaler wrote:
>> Isn't JSON defined in terms of ECMAScript?   http://json.org/ seems to so
>> indicate.  I see, however, that the JSON-LD document points at RFC 4627.  RFC
>> 4627 doesn't specify anything except a grammar, as far as I can see, although
>> it too points at ECMAScript.
> No, the JSON we use is RFC 4627. It was inspired by ECMAScript, but has a couple of important differences. Most notably numbers are of arbitrary size and precision and valid documents have to be arrays or objects at the top level.
>
>
>> I had some trouble trying to find the referenced document, European Computer
>> Manufacturers Association, "ECMAScript Language Specification 3rd Edition",
>> December 1999, as the document at
>> http://www.ecma-international.org/publications/files/ecma-st/ECMA-
>> 262.pdf is edition 5.1.
>>
>> I did finally find the referenced document. It has an unusual mapping
>> for numbers, but then
>> goes on to use IEEE floating point double as its numeric type.   It this
>> appears that the mapping for JSON numbers should be simple - just use
>> xsd:double as the type.  Of course, it's not really that simple - the
>> treatment of numbers in ECMAScript is truly mind-boggling, but in the end, a
>> numeric literal is a value of the Number type, and the Number type is a subset
>> of IEEE floating point double.  Edition 5.1 of ECMAScript does not appear to
>> have any changes that would disturb this relationship.
> Yes, that's one concrete implementation. Other implementations may have different value spaces.
>

Well then what is JSON?   Is it only defined in terms of implementations?  
Which ones count?  Can I build an implementation of JSON, and have it count?

Suppose that I wanted to find out about JSON numbers from JSON-LD. The JSON-LD 
document points me at RFC4627, plus it says that "[a] number is similar to 
that used in most programming languages", which isn't any help at all.  
RFC4627 points at ECMAScript Programming Language Standard, Third Edition, 
plus it provides a grammar for numbers (after providing the "similar" phrase) 
which is, in essence, the grammar commonly used for floating point numbers in 
most programming languages.  But this grammar doesn't say anything about that 
JSON numbers really are, instead only providing a syntax.

RFC4627 doesn't completely nail down the relationship between JSON and 
ECMAScript, only saying that "[JSON] is derived from the object literals of 
JavaScript".  "Derived from" could cover a multitude of relationships, but the 
only two real choices here are "subset of" and "different from".   "Different 
from" isn't helpful at all, so someone who wants to determine what JSON 
numbers should be is pretty much left with "subset of."

So one comes up with JSON numbers being a subset of ECMAScript, Version 3, 
numbers, which works out to IEEE floating point double minus NaNs, negative 0, 
and maybe infinities.


Of course, conforming JSON implementations can do lots of things. They could 
implement JSON numbers as strings, they could implement JSON numbers in base 
three, etc., etc.   However, they should (and it is very strange that the JSON 
specs don't support turning this should into something stronger) implement 
JSON numbers as if the numbers were turned into IEEE floating point double.   
However, when writing specifications on top of JSON any shoulds should be 
carried through.

peter

PS:  It appears that there is an IEEE working group set up to (re-)define JSON.

PPS: ECMAScript Version 5.1 provides a parser for JSON.   If JSON actually is 
defined in terms of the current version of ECMAScript, then this is the 
definition of how JSON documents are turned into data.

Received on Tuesday, 9 July 2013 12:29:51 UTC