Jena API が JSON-LD をサポートしていることはわかりませんが、RDF トリプルの直接エンコードであるRDF/JSON をサポートしています。Jena API を使用することもできますが、Jena でこれを行うより便利な方法は、Jena コマンド ラインrdfcat
ツールを使用することです。このオプションによって生成されるヘルプ メニュー--help
は少し古くなっていますが、次のようになります。
$ rdfcat --help
Usage: java jena.rdfcat (option|input)*
Concatenates the contents of zero or more input RDF documents.
Options: -out N3 | N-TRIPLE | RDF/XML | RDF/XML-ABBREV
-n expect subsequent inputs in N3 syntax
-x expect subsequent inputs in RDF/XML syntax
-t expect subsequent inputs in N-TRIPLE syntax
-[no]include include rdfs:seeAlso and owl:imports
input can be filename, URL, or - for stdin
Recognised aliases for -n are: -n3 -ttl or -N3
Recognised aliases for -x are: -xml -rdf or -rdfxml
Recognised aliases for -t are: -ntriple
Output format aliases: x, xml or rdf for RDF/XML, n, n3 or ttl for N3, t or ntriple for N-TRIPLE
See the Javadoc for jena.rdfcat for additional details.
それに加えて知りたいことは、出力フォーマットを渡すことができるということですRDF/JSON
。たとえば、よく知られている Pizza オントロジーを使用すると、次のようになります。
$ rdfcat -out RDF/JSON ../sparql-pizza2/pizza.owl | head -25
{
"_:-b8ef06:140ee02a0b1:-7ff7" : {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" : [ {
"type" : "uri" ,
"value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"
}
] ,
"http://www.w3.org/1999/02/22-rdf-syntax-ns#first" : [ {
"type" : "uri" ,
"value" : "http://www.co-ode.org/ontologies/pizza/pizza.owl#TomatoTopping"
}
]
}
,
"http://www.co-ode.org/ontologies/pizza/pizza.owl#Food" : {
"http://www.w3.org/2000/01/rdf-schema#subClassOf" : [ {
"type" : "uri" ,
"value" : "http://www.co-ode.org/ontologies/pizza/pizza.owl#DomainConcept"
}
] ,
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type" : [ {
"type" : "uri" ,
"value" : "http://www.w3.org/2002/07/owl#Class"
}
]
...and so on...