- From: Aymeric Brisse <aymeric.brisse@gmail.com>
- Date: Fri, 29 Jul 2016 14:44:54 +0200
- To: Gregg Kellogg <gregg@greggkellogg.net>
- Cc: public-linked-json@w3.org
- Message-ID: <CANURzhht22tRSPV8fC=018tPt_ELk2gzqCQGhjzU7h2dp0dZAQ@mail.gmail.com>
Hi Gregg, Thanks for the reply. I played with the JSON-LD Frame feature and it is pretty cool. The problem is that it seems to be a "feature in progress" since it only works on some case: *ISSUE 110* *Currently, framing allows just to select node definitions based on @type matching or duck typing for included properties. It allows value properties to be explicitly matched based on defining the property and excluding things that are undefined, but it does not allow to be more specific about the types of values selected. Allowing this is currently being discussed.* (Source: http://json-ld.org/spec/latest/json-ld-framing/) In my case to specify a root entity I would like to be able to specify an @id filter instead of a @type (since my root entity can be linked to other entities of the same type) frame = JSON.parse %({ "@context": { .... }, "@id": "http://www.myresource/uuid" }) What would you recommend? Adding a fake rdf:type for the JSON-LD serialization and remove it after? Thanks! On Thu, Jul 28, 2016 at 7:57 PM, Gregg Kellogg <gregg@greggkellogg.net> wrote: > Hi Aymeric, you probably want to specify a JSON-LD Frame to the serializer > to get the shape you want. You may need to manually get rid of a top-level > @graph, but that would allow you to specify the shape of the result. > > Gregg Kellogg > > Sent from my iPad > > On Jul 28, 2016, at 1:39 PM, Aymeric Brisse <aymeric.brisse@gmail.com> > 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): > > <?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> > > 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 Friday, 29 July 2016 12:45:44 UTC