HowTo – Load JSON-LD files into Virtuoso

HowTo – Load JSON-LD files into Virtuoso

The RDF_LOAD_JSON_LD( ) function enables the loading of JSON-LD files into Virtuoso, across multiple threads and as part of a transaction as required.


RDF_LOAD_JSON_LD( ) - enables the loading of JSON-LD files into Virtuoso.


       in strg varchar, 
       in base varchar, 
       in graph varchar := null, 
       in flags integer := 0, 
       in threads int := 3,
       in transactional int := 0,
       in log_enable int := null)


strg. - text of the resource

base - base IRI to resolve relative IRIs to absolute

graph - target graph IRI, parsed triples will appear in that graph.

flags - not used currently

threads - number of threads to use in call

transactional - enable or disable transactions

log_enable - controls transaction logging and in-statement autocommit as detailed at log_enable


Given the following JSON_LD file in the database directory :

$ cat test.jsonld 
  "@context": "",
  "@id": "",
  "name": "John Lennon",
  "born": "1940-10-09",
  "spouse": ""

It can be loaded into the database with the command:

SQL> rdf_load_json_ld (file_to_string('test.jsonld'),'', 'urn:test');

Done. -- 77 msec.

producing the following graph in the database:

SQL> sparql select * from <urn:test> where {?s ?p ?o};
s                                                                                 p                                                                                 o
LONG VARCHAR                                                                      LONG VARCHAR                                                                      LONG VARCHAR
_______________________________________________________________________________                                                                                     John Lennon                                                                                        1940-10-09                                                                                 

3 Rows. -- 1 msec.