Hi Florent,
Thanks a lot for the explanation. I got what I was looking for. Thanks, Arun From: [email protected] [mailto:[email protected]] On Behalf Of Florent Georges Sent: Thursday, March 09, 2017 8:42 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Dynamically convert JSON to triples Hi, Depends on your definition of "optimum". This definitely looks like a solution to me. Another one (among others) would be to create a new endpoint using SJS and send the JSON file straight there (the SJS just creating the triples on the fly). There is more than one way to skin a cat, especially on MarkLogic, and maybe especially WRT ingestion. Do you want to be optimal WRT dev time, budget, maintenance, execution speed, something else? Do you want to have as less dependency as possible, to be as fast as possible? If you use Java anyway and do not fear bad data injection (if you have enough control on the input or if it has been validated already), this at least looks like a solution to me. Still a bit of checks with the ID and name you use to concatenate the string would not harm, but I guess that was beyond the point of your question. Regards, -- Florent Georges H2O Consulting http://h2o.consulting/ On 9 March 2017 at 07:45, Arun K L wrote: Could someone please guide me if my below steps of converting JSON to triples is the optimum solution? Thanks, Arun From: [email protected] [mailto:[email protected]] On Behalf Of Arun K L Sent: Tuesday, March 07, 2017 3:48 PM To: 'MarkLogic Developer Discussion' Subject: Re: [MarkLogic Dev General] Dynamically convert JSON to triples Tony, Thanks for correcting me. Regards, Arun From: [email protected] [mailto:[email protected]] On Behalf Of Anthony Coates Sent: Tuesday, March 07, 2017 3:38 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Dynamically convert JSON to triples Classification: Public The range of < <http://dbpedia.org/ontology/name> 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/ <http://dbpedia.org/resource/%22%20+%20person.getID()%20+%20%22> " + person.getID() + "> <http://dbpedia.org/ontology/name> <http://dbpedia.org/resource/ <http://dbpedia.org/resource/%22%20+%20person.getName()%20+%20%22> " + person.getName() + "> ."; 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
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
