Re: Example of using json-ld from Java

Hi Viggo,


I work for Acando in Norway and we've been experimenting with putting JSON-LD into Elasticsearch for DIFI.


The only technical issue with putting JSON-LD in Elasticsearch is that Elasticsearch doesn't allow URIs as properties in JSON. So if you have a framing with proper namespaces then there is no problem putting your JSON-LD in Elasticsearch.


For querying though, we ran across quite a few hurdles, which in our case led us to use Apache Jena in Java for parsing the JSON-LD, and then building a POJO and converting it to JSON with GSON. This worked fairly well.


Along the way though, we discovered that the only reason we had to do this, was because there was no way of forcing JSON-LD into a specific format if your string literals were both with and without a language tag. If you are consistent with using language tags, then you can "easily" frame your JSON-LD into a consistent JSON format and drop your context and graph parts to get simple JSON.


Regards,

Håvard M. Ottestad


________________________________
From: Viggo Navarsete <viggo.navarsete@gmail.com>
Sent: Friday, February 19, 2016 9:13 PM
To: Dietrich Schulten
Cc: public-linked-json@w3.org
Subject: Re: Example of using json-ld from Java


I plan to put my json-ld into elasticsearch, so I might also just use Jackson,thanks for advice.

fre. 19. feb. 2016, 21.11 skrev Dietrich Schulten <ds@escalon.de<mailto:ds@escalon.de>>:

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<mailto: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 Sunday, 21 February 2016 16:45:16 UTC