W3C home > Mailing lists > Public > public-rdf-wg@w3.org > March 2011

Re: [JSON] I say again, what *is* JSON?

From: Gavin Carothers <gavin@topquadrant.com>
Date: Thu, 24 Mar 2011 10:56:39 -0700
Message-ID: <AANLkTik98QJfGcUdgyB=S4gvMFUFz7aRES9fCWHhHgPo@mail.gmail.com>
To: Peter Frederick Patel-Schneider <pfps@research.bell-labs.com>
Cc: public-rdf-wg@w3.org, nathan@webr3.org
On Thu, Mar 24, 2011 at 10:06 AM, Peter Frederick Patel-Schneider
<pfps@research.bell-labs.com> wrote:
> From: Gavin Carothers <gavin@topquadrant.com>
> Subject: Re: [JSON] I say again, what *is* JSON?
> Date: Thu, 24 Mar 2011 10:53:25 -0500
>> On Thu, Mar 24, 2011 at 7:35 AM, Peter Frederick Patel-Schneider
>> <pfps@research.bell-labs.com> wrote:
>>> Hmm.
>>> Is this really the JSON spec?
>> No.
>> [... snip ...]
>>> So, I ask again, is there a definition JSON somewhere around?
>> Yes,  http://www.ietf.org/rfc/rfc4627.txt  it is "just" a grammar.
> I note that the character encoding here appears to be different from
> that in the JavaScript document.

Yep, I believe most JavaScript JSON parsers rely on the browser to "Do
the right thing", which they do.

>> The
>> mapping of JSON into the object model of the parsers language is not
>> specified.
> So then, how can the WG talk about round-tripping, etc., etc.?

A JSON object that is parsed into a language is -likely- to be
serialized back out the same way. Exactly what it looks like while in
the language isn't part of JSON, but is part of JavaScript.

>> From section 2.2:
>> The names within an object SHOULD be unique.
> Hmm.  This doesn't appear in json.org or in the JavaScript document.
>> While it does say SHOULD, but it is in reality a MUST.
> Except that there are lots of "MUST"s in the document, so one SHOULD be
> able to have non-unique names, if the circumstances warrant.

Right, if we look at the YAML spec
http://yaml.org/spec/1.2/spec.html#id2759572 (of which JSON is a
subset) we find:

JSON's RFC4627 requires that mappings keys merely “SHOULD” be unique,
while YAML insists they “MUST” be. Technically, YAML therefore
complies with the JSON spec, choosing to treat duplicates as an error.
In practice, since JSON is silent on the semantics of such duplicates,
the only portable JSON files are those with unique keys, which are
therefore valid YAML files.

>> --Gavin
> peter
Received on Thursday, 24 March 2011 17:57:13 UTC

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