Re: Introduction and a question about JSON-LD

Hi Dimitri,

I guess it's a matter of style.

One could also use an array to give multiple values for schema:homeTown

"homeTown": ["Tilburg" ,
"http://standaarden.overheid.nl/owms/terms/Tilburg_(gemeente)" ,
"http://dbpedia.org/page/Tilburg"]

I'm not sure that a resource about Dimitri would be the logical place to make
equivalence links between overheid.nl and DBpedia URIs.
Of course you can argue that if you know the client needs this information, then
it is logical to include it in the response.
However you could also say that a linked data application should "follow it's
nose" and dereference those links to gather more info.

That's a similar discussion to what we've talked about before regarding
including the display labels for properties and referenced things in the
response, or requiring a second request to somehow fetch those.

John

> On July 27, 2014 at 10:03 AM Dimitri van Hees <info@dimitrivanhees.com> wrote:
>
>  Hi John,
>   
>  Yeah, anyone can say anything about anything, but in the end I'd like to let
>the consumer decide. As the API provider, I can create a link to DBpedia or to
>data.freshheads.com with seeAlso links available. But on the other hand, if we
>take the postcode API for example, people ask me to link to the official
>government standards of municipalities. For the consumer it's nicer to have a
>link to DBpedia.
>   
>  Is it by the way also possible to define those links directly in the
>response? Something like:
>   
>  "homeTown": {
>    "@id" : " http://standaarden.overheid.nl/owms/terms/Tilburg_(gemeente)",
>    {
>      "rdfs:seeAlso": "http://dbpedia.org/page/Tilburg"
>    }
>  }
>   
>  Of course it's possible, but would it make sense?
>   
>
>  Van: John Walker <mailto:john.walker@semaku.com>
>  Verzonden: ‎vrijdag‎ ‎25‎ ‎juli‎ ‎2014 ‎22‎:‎37
>  Aan: public-hydra@w3.org <mailto:public-hydra@w3.org> ,
>markus.lanthaler@gmx.net <mailto:markus.lanthaler@gmx.net> , Dimitri van Hees
><mailto:info@dimitrivanhees.com>
>   
>  Hi Dimitri,
>
>  I took the liberty to modify your original a little bit:
>
>  {
>    "@context": [
>      "
>https://rawgit.com/json-ld/json-ld.org/master/contexts/schema.org.jsonld",
>      {
>        "@base": " http://data.freshheads.com/",
>        "id": "@id",
>        "type": "@type"
>      }
>    ],
>    "id": "dimitri",
>    "type": "Person",
>    "givenName": "Dimitri",
>    "additionalName": "van",
>    "familyName": "Hees",
>    "gender": "male",
>    "homeLocation": "Tilburg"
>  }
>
>  I combined an external and local context as shown in example 29 of Advanced
>  Context Usage section of the JSON-LD spec [1].
>  As you can see I used the Schema.org context off GitHub served via RawGit so
>  that it plays nice in the JSON-LD playground.
>  Ideally you would just need to use " http://schema.org/", but that doesn't
>work
>  in the playground (guess it sends wrong Accept header when fetching the
>  context).
>
>  Anyway, when you look at the N-Quads output, you'll see that Tilburg is
>  magically turned into the URI < http://data.freshheads.com/Tilburg> (which
>has
>  been resolved against the @base URI).
>
>  A client that followed that link would hopefully find more JSON-LD there that
>  describes Tilburg.
>  That might include a schema:sameAs link to the Wikipedia page, Freebase page,
>or
>  official website for Tilburg.
>
>  Of course you might decide to just link directly to an existing URI, but
>minting
>  your own URI would also give Freshheads the possibility to publish your own
>  description of Tilburg (remember Anyone can say Anything about Anything :) ).
>
>  Groetjes,
>  John
>
>  [1] http://www.w3.org/TR/json-ld/#advanced-context-usage
>
>
>  > On July 25, 2014 at 7:45 PM Markus Lanthaler <markus.lanthaler@gmx.net>
>wrote:
>  >
>  >
>  > Hi Dimitri,
>  >
>  > On Thursday, July 24, 2014 12:36 PM, Dimitri van Hees wrote:
>  > > I've been following this list for a few months now but have not yet
>  > > been in the opportunity to introduce myself or contribute anything. As
>  > > I have a question about JSON-LD, I think this might be the right time
>  > > to do so ;-)
>  >
>  > Great! Good to see you here :-)
>  >
>  >
>  > > That said, it was time for me to actually start implementing this
>  > > model in our own API's. For this purpose we created a demo API which
>  > > represents our 26 employees, including birthdates, hometowns, hobbies,
>  > > functions, education, etc. I want to add Hydra in the JSON-LD
>  >
>  > Cool!
>  >
>  >
>  > > representation, HATEOAS in the JSON representation (does that sound
>  > > reasonable by the way?)
>  >
>  > Sounds a bit weird to me as HATEOAS is a description of what drives the
>  > application. I would say "add hypermedia controls to JSON" instead.
>  >
>  >
>  > > and also provide an application/nquads
>  > > representation to fetch the triples and load them into a triplestore
>  > > one by one.
>  > >
>  > > After spending hours reading the documentation I still can't find what
>  > > I'm doing wrong with the conversion to JSON-LD. I hope this list will
>  > > help me out a little bit. Let's say I have this response (in real life
>  > > this is valid JSON but my mail client sucks at the moment 😉):
>  > >
>  > > id: dimitri,
>  > > givenName: Dimitri,
>  > > additionalName: van,
>  > > familyName: Hees,
>  > > gender: male,
>  > > birthplace: Nijmegen,
>  > > residence: Tilburg
>  > >
>  > > As you might have noticed the properties are all schema.org except
>  > > birthplace and residence. When converting this to JSON-LD I think I
>  > > could say:
>  > >
>  > > @context: {
>  > > schema: http://schema.org/,
>  > > givenName: {@id: schema:givenName},
>  > > addition…
>  > > birthplace: {@id: schema:City, @type: @id},
>  > > residence: {@id: schema:City, @type: @id},
>  >
>  > These two mappings here are the problem. You map two properties, birthplace
>  > and residence to schema:City which isn't a property but a class. There's no
>  > property for birthplace in Schema.org yet (I think it would make sense to
>  > propose one on public-vocabs@w3.org). For residence, you could use either
>  > schema:homeLocation or schema:workLocation.
>  >
>  >
>  > > },
>  > > @id: http://data.freshheads.com/dimitri,
>  > > givenName: Dimitri,
>  > > additon…,
>  > > birthplace: {
>  > > @id: http://www.nijmegen.nl
>  > > },
>  > > residence: {
>  > > @id: http://www.tilburg.nl
>  > > }
>  > >
>  > > The problem is that both birthplace and residence are being converted
>  > > to City while they don't seem to be an actual 'City' anymore. When I
>  > > add it to the valueobject itself:
>  > >
>  > > birthplace: {
>  > > @id: http://www.nijmegen.nl
>  > > @type: http://schema.org/City
>  > > }
>  > >
>  > > then it works they way I'd expect. But I don't really understand why.
>  > > Any thoughts?
>  >
>  > Type coercion in the context only works for literals, i.e., simple strings.
>In
>  > other words, you can convert a simple string to an @id object by setting
>  > @type: @id or to a @value object with a @type by setting @type to the
>desired
>  > datatype in the context. Please not that you can NOT type nodes (@id
>objects)
>  > from within the context. You need to do so directly in the document itself.
>  > Node types and value types are treated differently.
>  >
>  >
>  > HTH,
>  > Markus
>  >
>  >
>  > --
>  > Markus Lanthaler
>  > @markuslanthaler
>  >
>  >
>  >
>  >
>

 

Received on Sunday, 27 July 2014 08:55:18 UTC