- From: Håvard Mikkelsen Ottestad <haavard.ottestad@acando.no>
- Date: Thu, 28 Jul 2016 21:06:24 +0000
- To: David Booth <david@dbooth.org>, "public-linked-json@w3.org" <public-linked-json@w3.org>
- Message-ID: <HE1PR02MB138645C95E07F0423C7BE6FF9C000@HE1PR02MB1386.eurprd02.prod.outlook.com>
How about this frame: { "@context": { "rdfs": "http://www.w3.org/2000/01/rdf-schema#" }, "http://www.myresource.com/ontology/1.0#talksAbout": { "@embed":true } } Regards, Håvard Ottestad ________________________________ From: David Booth <david@dbooth.org> Sent: Thursday, July 28, 2016 8:00:11 PM To: public-linked-json@w3.org Subject: Re: JSON-LD & nested structure I hope others who are more familiar with JSON-LD framing will answer your question, but . . . On 07/28/2016 01:39 PM, Aymeric Brisse wrote: > Hello, > > I am currently working on a API that would return some JSON-LD and face > some problematic. I would like to know, when transforming a graph to > JSON-LD, how to be able to avoid the @graph object generation and having > a nested hash instead (I assume that I have a root element). > > The idea is to have a structure more /traditional/ for the developers > that want to parse it as a simple JSON object. > > Let's say I have to following graph (rdf/xml for readability): Funny. I think rdf/xml is the *least* readable of RDF serializations! > > <?xml version='1.0' encoding='utf-8' ?> > <rdf:RDF xmlns:ns0='http://www.myresource.com/ontology/1.0#' > xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' > xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'> > <rdf:Description rdf:about='http://www.myresource/uuid'> > <ns0:talksAbout> > <rdf:Description rdf:about='http://rdf.freebase.com/ns/m.018w8'> > <rdfs:label xml:lang='en'>Basketball</rdfs:label> > </rdf:Description> > </ns0:talksAbout> > </rdf:Description> > </rdf:RDF> Here is the same thing in turtle, for the benefit of other readers: @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix ns0: <http://www.myresource.com/ontology/1.0#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . <http://rdf.freebase.com/ns/m.018w8> rdfs:label "Basketball"@en . <http://www.myresource/uuid> ns0:talksAbout <http://rdf.freebase.com/ns/m.018w8> . Thanks, David Booth > > Basically when I use a standard serializer like the jsonld gem in Ruby > to serialize it in JSON-LD I obtain (reproducible on > http://rdf.greggkellogg.net/distiller) > > { > "@context": { > "rdfs": "http://www.w3.org/2000/01/rdf-schema#" > }, > "@graph": [ > { > "@id": "http://rdf.freebase.com/ns/m.018w8", > "rdfs:label": [ > { > "@value": "Basketball", > "@language": "en" > } > ] > }, > { > "@id": "http://www.myresource/uuid", > "http://www.myresource.com/ontology/1.0#talksAbout": [ > { > "@id": "http://rdf.freebase.com/ns/m.018w8" > } > ] > } > ] > } > > But I would like to obtain: > > { > "@context": { > "rdfs": "http://www.w3.org/2000/01/rdf-schema#" > }, > "@id": "http://www.myresource/uuid", > "http://www.myresource.com/ontology/1.0#talksAbout": [ > { > "@id": "http://rdf.freebase.com/ns/m.018w8", > "rdfs:label": [ > { > "@value": "Basketball", > "@language": "en" > } > ] > } > ] > } > > Is there any option or way to do it? > > Thanks!
Received on Thursday, 28 July 2016 21:06:58 UTC