Classification: Public
The range of <http://dbpedia.org/ontology/name> is 'rdf:langString', so the 
object shouldn't be an IRI, it should be a string, possibly with a language 
specifier as appropriate.

Cheers, Tony.

From: [email protected] 
[mailto:[email protected]] On Behalf Of Arun K L
Sent: 07 March 2017 10:02
To: [email protected]
Subject: [MarkLogic Dev General] Dynamically convert JSON to triples

Greetings All,

We have an app where we use MarkLogic Java client API to communicate with 
MarkLogic DB.

We are working on converting JSON documents to triples data as and when the 
JSON doc is ingested.
We are achieving this via below steps.


1.       Suppose the incoming JSON is as below:
{"id":"100", "name":"john"}


2.       Convert this into NT format like below. Please note that no tools are 
used for this conversion. The properties are read and set to Java Strings.

a.       Read the JSON string and set it to Person object

b.      Get the values and set it in below string
String triple = "<http://dbpedia.org/resource/"; + person.getID() + 
"<http://dbpedia.org/resource/%22%20+%20person.getID()%20+%20%22>> 
<http://dbpedia.org/ontology/name> <http://dbpedia.org/resource/"; + 
person.getName() + 
"<http://dbpedia.org/resource/%22%20+%20person.getName()%20+%20%22>> .";


3.       Now use StringHandle using which the triples data is ingested into 
MarkLogic DB using graphManager.write() method.
StringHandle handle = new 
StringHandle(triple).withMimetype(RDFMimeTypes.NTRIPLES);

Using this approach we are able to see the triples data 
(http://localhost:8000/v1/graphs/things) as expected.

The question is: is this the right approach to dynamically convert JSON to 
triples? Or is there any better way to do this, say using XQuery or Javascript 
functions/scripts?

Any guidance is much appreciated!

Thanks,
Arun



---
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to https://www.db.com/disclosures for additional EU corporate and 
regulatory disclosures and to 
http://www.db.com/unitedkingdom/content/privacy.htm for information about 
privacy.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to