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

> \On Nov 22, 2014, at 4:21 PM, François-Paul Servant <francoispaulservant@gmail.com> wrote:
> 
> Nicholas, John,
> 
> thanks for the comments and pointers.
> 
> What I would need is an ordered list of (prop, value) pairs (-- not of values)
> 
> Ex, I have the following graph (in turtle):
> s
> 	p1 o11,o12,o13;
> 	p2 o21,o22,o23.
> 
> Easy to represent in JSON-LD using arrays. However, I'd like to show the following to a human reader:
> s
> 	p1 o11;
> 	p2 o21;
> 	p1 o12;
> 	p2 o22;
> 	p3 o13;
> 	p3 o23.
> 
> The ordering is not really meaningful, just nicer for the human that looks at it. So, this is basically how I'd like to have the data displayed to an end user.
> 
> My problem is to transmit these data to a program in charge of creating a web page that displays them, and in charge also of publishing the RDF data for other programs (the RDF graph is the only thing that matters, as far as machines are concerned, except for the program in charge of displaying it to human users)
> 
> I've been using RDFa, but it's difficult to have the people in charge of creating web pages to take care of that.
> 
> I was hoping to transmit some JSON-LD that mimics the second form of the graph above, thinking that the web developer would then easily convert it to HTML, and include it in a script in order to also have the data published as data. Until I found that duplicate keys are not possible… (I know well RDF things, but I have little experience with JSON)

Only real way to use separate values is to use separate objects, such as:

[{
  “@id”: “s”,
  “p1”: “o11”
},{
  “@id”: “s”,
  “p2”: “o21”,
},{
  “@id”: “s”,
  “p1”: “o12”,
},{
  “@id”: “s”,
  “p2”: “o22”,
},{
  “@id”: “s”,
  “p3”: “o13”,
},{
  “@id”: “s”,
  “p3”: “o23”,
}]

A more natural way with JSON-LD would be to simply combine values using an array (similar to the Turtle representation):

{
  “@id”: “s”,
  “p1”: [“o11”, “o12”, “o13”],
  “p2”: [“o21”, “o22”, “o23]
}

This really goes for most JSON, although only JSON-LD treats these all as the same entity when you flatten and compact.

Gregg

> Example of the data I'm working with:
> - in RDFa:
> http://uk.co.rplug.renault.com/product/model/87J/captur/c/A-87J-NAV3G3?embed=true <http://uk.co.rplug.renault.com/product/model/87J/captur/c/A-87J-NAV3G3?embed=true>
> - in turtle (not exactly the same data as above, but almost)
> http://uk.co.rplug.renault.com/product/model/87J/captur/c/A-87J-NAV3G3?as=ttl <http://uk.co.rplug.renault.com/product/model/87J/captur/c/A-87J-NAV3G3?as=ttl>
> 
> Best,
> 
> fps
> Le 22 nov. 2014 à 18:37, Nicholas Bollweg <nick.bollweg@gmail.com <mailto:nick.bollweg@gmail.com>> a écrit :
> 
>> Can you help us with a few examples of what you are trying to represent? I am inclined to believe that @list might be your only way to get ordering without reimplementing it yourself!
>> 
>> Also, here's the ECMAScript discussion about duplicate keys:
>> 
>> https://esdiscuss.org/topic/json-duplicate-keys <https://esdiscuss.org/topic/json-duplicate-keys>
>> 
>> The minutes at the end are actually quite informative about how things like this happen and the choices such committees have to make.
> 

Received on Monday, 24 November 2014 20:59:35 UTC