W3C home > Mailing lists > Public > public-hydra@w3.org > July 2014

Introduction and a question about JSON-LD

From: Dimitri van Hees <info@dimitrivanhees.com>
Date: Thu, 24 Jul 2014 19:35:52 +0000
Message-ID: <BAY403-EAS2077ECF135D492DF499D49CBFFF0@phx.gbl>
To: "public-hydra@w3.org" <public-hydra@w3.org>
Hi,


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 ;-)






My name is Dimitri van Hees and I am a technical architect at Freshheads, a Dutch internet agency. In this role I am responsible for our 'data strategy', trying to improve our applications for our customers using Big, Linked and/or Open Data, API's, etc. For the past 6 months I've been part of the Dutch Linked Open Data programme investigating cases about how to bring Linked Data to the next level in The Netherlands. As one of the few developer oriented people between all the 'academics', I have been struggling with exactly the problems JSON-LD seem to solve.


That's why I've rewritten the famous 5 Stars of Linked Open Data of Tim Berners-Lee to a 6 Star model, saying that after CSV (3 stars) you should provide a RESTful JSON API (4 stars), add context and links to that API using JSON-LD (5 stars) and convert it to RDF and put it in a triplestore to query it with SPARQL (6 stars).


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 representation, HATEOAS in the JSON representation (does that sound reasonable by the way?) 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},

},

@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?


Thanks in advance!


Dimitri van Hees

Twitter: @dvh
Received on Friday, 25 July 2014 11:35:18 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:29:42 UTC