W3C home > Mailing lists > Public > public-linked-json@w3.org > February 2016

Re: Example of using json-ld from Java

From: Dietrich Schulten <ds@escalon.de>
Date: Fri, 19 Feb 2016 21:11:18 +0100
Message-ID: <33f702a2-6417-41c5-9027-86a2364a9d28@escalon.de>
To: Viggo Navarsete <viggo.navarsete@gmail.com>
Cc: public-linked-json@w3.org
I normally use plain json to java bean mapping, e.g. with Jackson. I don't have triple stores as my backend.
A core advantage of jsonld is, it is still json, so that normal json tooling can be used.

If you really want to work with the response as rdf, did you check Apache Jena? It has a json-ld adapter.

[1] https://jena.apache.org/tutorials/rdf_api.html#ch-Navigating a Model

Am 19.02.2016 11:36 schrieb Viggo Navarsete <viggo.navarsete@gmail.com>:

Question also sent to IRC channel:

Hi, is there someone who can help me with parsing json-d from Java? I see that from javascript it's relatively easy to traverse the json-ld structure, see this example: http://www.autoidlabs.org.uk/GS1Digital/Demos/GS1vocab/gs1JSON-LD-with-JavaScript.html. But I'm always ending up casting to several layers of LinkedHashMap to get to the data I want to use/test. Am I modelling things wrong or using Expansion/Compaction/Flattening/Framing in a way that makes me end up with all these LinkedHashMaps I need to "unpack" to get to the level in the json-ld structure I want to read?
This is an example where I've tried to fetch an attribute from a json-ld structure from java, and I used flatten algorithm first (even not sure if that is best practise), and as you can see it's not as elegant as done in Javascript :( http://pastie.org/10727293


Regards,

Viggo Navarsete
Received on Friday, 19 February 2016 20:11:53 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:47 UTC