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.
Name
RDF_LOAD_JSON_LD( ) - enables the loading of JSON-LD files into Virtuoso.
Synopsis
DB.DBA.RDF_LOAD_JSON_LD(
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)
Parameters
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
Example
Given the following JSON_LD
file in the database directory :
$ cat test.jsonld
{
"@context": "https://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
}
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.
SQL>
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
_______________________________________________________________________________
http://dbpedia.org/resource/John_Lennon http://xmlns.com/foaf/0.1/name John Lennon
http://dbpedia.org/resource/John_Lennon http://schema.org/birthDate 1940-10-09
http://dbpedia.org/resource/John_Lennon http://schema.org/spouse http://dbpedia.org/resource/Cynthia_Lennon
3 Rows. -- 1 msec.
SQL>