- From: Anders Riutta <anders.riutta@gladstone.ucsf.edu>
- Date: Wed, 4 Jun 2014 19:53:47 -0700 (PDT)
- To: public-linked-json@w3.org
Thanks, Niklas and John. This was helpful. For reference for anyone else, you can see the working example at the JSON-LD playground here: http://tinyurl.com/naj5zep
----- Original Message -----
> From: "john.walker" <john.walker@semaku.com>
> To: "Niklas Lindström" <lindstream@gmail.com>
> Cc: public-linked-json@w3.org
> Sent: Wednesday, June 4, 2014 5:36:10 AM
> Subject: Re: Mapping predefined values to URIs when interpreting JSON as JSON-LD
>
> Hi Niklas,
>
> Thanks, works like a charm.
>
> So that can also be used the other direction to map from a URI in object
> position of a triple in JSON-LD to some label required by an application that
> consumes 'regular' JSON.
>
> John
>
>
> > On June 3, 2014 at 10:13 PM Niklas Lindström <lindstream@gmail.com> wrote:
> >
> > Hi John,
> >
> > To resolve values as context keys (or against @vocab), you need to use
> > @type:
> > @vocab, e.g.:
> >
> > "property1": {
> > "@id": " http://example.com/vocab#foo",
> > "@type": "@vocab"
> > }
> >
> > The difference between this and @type: @id is that @id coercion resolves
> > values against the document URI (or @base, or by expanding prefixes). It
> > thus
> > treats your values as relative paths. (This ensures that relative paths
> > don't
> > collide with terms.) Using @type: @vocab instead looks in "vocabulary
> > space"
> > first.
> >
> > Cheers,
> > Niklas
> >
> >
> >
> > On Tue, Jun 3, 2014 at 9:53 PM, john.walker <john.walker@semaku.com
> > <mailto:john.walker@semaku.com> > wrote:
> > > > I'm looking for some help/guidance with context usage.
> > >
> > > Say I have an existing JSON document:
> > >
> > > {
> > > "property1": "value1",
> > > "property2": "value2"
> > > }
> > >
> > > I'm struggling with mapping this to existing URIs.
> > > Say:
> > > property1 => http://example.com/vocab#foo
> > > property2 => http://example.com/vocab#bar
> > > value1 => http://example.com/vocab#baz
> > > value2 => http://example.com/vocab#qux
> > >
> > > So the triples I'm looking to derive are:
> > >
> > > _:b0 < http://example.com/vocab#bar> < http://example.com/vocab#baz> .
> > > _:b0 < http://example.com/vocab#foo> < http://example.com/vocab#qux> .
> > >
> > > I tried with this context:
> > >
> > > {
> > > "@context": {
> > > "property1": {
> > > "@id": " http://example.com/vocab#foo",
> > > "@type": "@id"
> > > },
> > > "property2": {
> > > "@id": " http://example.com/vocab#bar",
> > > "@type": "@id"
> > > },
> > > "value1": " http://example.com/vocab#baz",
> > > "value2": " http://example.com/vocab#qux"
> > > }
> > > }
> > >
> > > But this does not do the desired mappings for the values, instead the
> > > values are
> > > just interpreted relative to the base/current URI.
> > >
> > > It feels like I'm missing something obvious...
> > >
> > > Cheers,
> > > John
> > >
> > >
> > > >
>
>
Received on Thursday, 5 June 2014 02:54:12 UTC