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: Andy Seaborne <andy@seaborne.org>
Date: Sat, 22 Nov 2014 14:42:03 +0000
Message-ID: <5470A0BB.8010204@seaborne.org>
To: public-linked-json@w3.org
JSON does not allow repeating keys.

While it is legal by the JSON grammar, what is going to happen is undefined.

RFC7159 : "The names within an object SHOULD be unique."

more discussion and quotes from RFC 7159
http://stackoverflow.com/questions/21832701/does-json-syntax-allow-duplicate-keys-in-an-object

JSON-LD builds on JSON so there isn't really a choice point here.

	Andy

On 22/11/14 13:55, François-Paul Servant 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 14:42:33 UTC

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