W3C home > Mailing lists > Public > public-linked-json@w3.org > November 2014

Re: "in #JSON-LD the keys in objects must be unique" -- why?

From: Franšois-Paul Servant <francoispaulservant@gmail.com>
Date: Sat, 22 Nov 2014 17:24:54 +0100
Cc: "public-linked-json@w3.org" <public-linked-json@w3.org>
Message-Id: <1134A45F-79F8-4346-8E84-7B63C0667111@gmail.com>
To: Niklas Lindstr÷m <lindstream@gmail.com>
Niklas, Andy,

thank you very much for your answers. Less disappointed? well, as Andy puts it: "there isn't really a choice point here" ;-)

Thanks!

(still thinking: what's the best way to write the data about a resource s - s,p,o triples, plus short description of the objects, eg. their labels - with an ordering of the prop-value pairs that depend on the objects, not the predicates)

Best Regards,

fps


Le 22 nov. 2014 Ó 15:28, Niklas Lindstr÷m <lindstream@gmail.com> a Úcrit :

> This is because JSON itself does not, in practice, support multiple keys with the same name. Specifically, the RFC [1] says "the names within an object SHOULD be unique", but implementations commonly throw away all but the last value (see e.g. [2] and [3]). This implementation behavior makes it basically impossible for JSON-LD parsers relying on an underlying JSON parser from detecting and warning about it, unless the underlying parser has support for that.
> 
> To overcome this mismatch between the JSON and RDF data models, JSON-LD handles arrays of values as sets of predicate, value pairs, and instead has a special construct, @list, to explicitly provide a way of representing closed, ordered RDF collections. You can also control this in compact form by using the @container feature with the @set and @list keywords. See the JSON-LD Syntax [4] for the details.
> 
> I hope this makes you less disappointed. :)
> 
> Cheers,
> Niklas
> 
> [1]: http://www.ietf.org/rfc/rfc4627.txt
> [2]: http://stackoverflow.com/questions/21832701/does-json-syntax-allow-duplicate-keys-in-an-object
> [3]: http://stackoverflow.com/questions/5306741/do-json-keys-need-to-be-unique
> [4]: http://www.w3.org/TR/json-ld/#sets-and-lists
> 
> 
> On Sat, Nov 22, 2014 at 2:55 PM, Franšois-Paul Servant <francoispaulservant@gmail.com> wrote:
> As I am a bit disappointed by the fact that keys in JSON-LD objects must be unique, I've tried to understand why it is so (as keys are properties, I didn't expect such a restriction - I know that we can use an array for multi-valued properties, but I would have expected that repeating a key would just have added more values - more triples to the graph). I've not been able to find an explanation (I tried searching this list without result, but I may have missed it). Could someone point me to some explanation / discussion on the topic? (it seems to me that I would be less disappointed if I understood why things are the way they are)
> 
> BTW, If you pass some JSON-LD that does not respect this rule to the playground (OK, not JSON-LD, then), you don't get any error or warning message (it seems that the latest value is used in the result)
> 
> Best,
> 
> fps
> 
> 
> 


Received on Saturday, 22 November 2014 16:25:23 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:42 UTC