- From: Aymeric Brisse <aymeric.brisse@gmail.com>
- Date: Wed, 17 Aug 2016 18:28:34 +0200
- To: Gregg Kellogg <gregg@greggkellogg.net>
- Cc: Dave Longley <dlongley@digitalbazaar.com>, JSON-LD CG <public-linked-json@w3.org>
- Message-ID: <CANURzhgEutRKYa8cFUOBFNRe7a0jOVyqLWWAtnqLPW_r58CQPw@mail.gmail.com>
Hello Gregg & Dave, I am currently dealing with another problem. Let's say 2 resources are linked together by more than 1 predicate. As a JSON API developer that wants to return a tree and not a graph I expect that the following LD framed graph... { "@context": { "kb": "http://www.perfect-memory.com/resource/", "pmcore": "http://www.perfect-memory.com/ontology/pmcore/1.0#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#" }, "@graph": [ { "@id": "kb:5644b184-8917-40b3-a2d9-370ac1154d8a", "@type": [ "pmcore:Text" ], "pmcore:relA": { "@id": "kb:14e0a970-ad07-45b6-a675-3c2e3551c5ea", "@type": [ "pmcore:Entity" ], "http://purl.org/dc/elements/1.1/description": { "@language": "fr", "@value": "Description" }, "rdfs:label": { "@language": "fr", "@value": "Child Object" } }, "pmcore:relB": { "@id": "kb:14e0a970-ad07-45b6-a675-3c2e3551c5ea", "@type": [ "pmcore:Entity" ], "http://purl.org/dc/elements/1.1/description": { "@language": "fr", "@value": "Description" }, "rdfs:label": { "@language": "fr", "@value": "Child Object" } }, "rdfs:label": { "@language": "fr", "@value": "Root Object" } } ] } ... to duplicate some parts of it if needed { "@context": { "kb": "http://www.perfect-memory.com/resource/", "pmcore": "http://www.perfect-memory.com/ontology/pmcore/1.0#", "rdfs": "http://www.w3.org/2000/01/rdf-schema#" }, "@graph": [ { "@id": "kb:5644b184-8917-40b3-a2d9-370ac1154d8a", "@type": [ "pmcore:Text" ], "pmcore:relA": { "@id": "kb:14e0a970-ad07-45b6-a675-3c2e3551c5ea", "@type": [ "pmcore:Entity" ], "http://purl.org/dc/elements/1.1/description": { "@language": "fr", "@value": "Description" }, "rdfs:label": { "@language": "fr", "@value": "Child Object" } }, "pmcore:relB": { "@id": "kb:14e0a970-ad07-45b6-a675-3c2e3551c5ea" }, "rdfs:label": { "@language": "fr", "@value": "Root Object" } } ] } That way the developper don't have to deal with an identitymap pattern just to parse the JSON, meaning that he can access directly to the hash object["pmcore:relB"]["rdfs:label"]["@value"] How can it be achieved in an automatic manner? Thank you, Aymeric On Thu, Aug 11, 2016 at 6:09 PM, Aymeric Brisse <aymeric.brisse@gmail.com> wrote: > Hello Gregg, > > LGTM. It works on my previous example. > > Cheers! > > On Thu, Aug 4, 2016 at 1:41 AM, Gregg Kellogg <gregg@greggkellogg.net> > wrote: > >> Thanks Dave, that did it. Aymeric, I’ve checked in the fix on the develop >> branch, see if that does what you need and I’ll release a new version. >> >> Gregg Kellogg >> gregg@greggkellogg.net >> >> > On Aug 3, 2016, at 6:55 AM, Dave Longley <dlongley@digitalbazaar.com> >> wrote: >> > >> > On 08/02/2016 03:47 PM, Gregg Kellogg wrote: >> >>> On Jul 29, 2016, at 9:04 AM, Dave Longley >> >>> <dlongley@digitalbazaar.com> wrote: >> >>> >> >>> On 07/29/2016 11:55 AM, Aymeric Brisse wrote: >> >>>> @Gregg : I cannot assume that the property will only be used by >> >>>> the top-level element. >> >>>> >> >>>> @Dave : already tried it but it doesn't work >> >>> >> >>> I modified Gregg's example and it worked for me: >> >>> >> >>> http://json-ld.org/playground/#/gist/bd569269ce69a8fe7ecebde0713acc73 >> >> >> >>> >> >> Dave, I do have the support for supporting value matching on @id, >> >> but the reason this doesn’t work for me is that when the frame is >> >> expanded, it returns an empty array, rather than one containing on >> >> object with the expanded @id. If you take the frame from the >> >> playground link and expand it, you’ll get the same thing. Yet, when >> >> used for framing, your processor seems to act as if the frame is not >> >> empty. >> > >> > The JavaScript processor has an option `keepFreeFloatingNodes` that it >> > sets to `true` prior to expanding a frame. Frames need a few special >> > rules applied during expansion in order to preserve the user's intent in >> > the output: >> > >> > https://github.com/digitalbazaar/jsonld.js/blob/master/js/js >> onld.js#L558-L559 >> > >> > You'll see there is also an `isFrame` option there that is later used to >> > ensure that an error is not thrown if `@id` is used with an `object` >> > value instead of a `string`. This allows people to construct frames to >> > select something that has an `@id` property without needing to >> > specify its value; of course, you can also specify it like we do in the >> > case at hand. >> > >> > >> > -- >> > Dave Longley >> > CTO >> > Digital Bazaar, Inc. >> > http://digitalbazaar.com >> >> >
Received on Wednesday, 17 August 2016 16:29:27 UTC