On 25/02/13 15:14, Alison Callahan wrote:
Hello all,
I am using Jena 2.6.4, and I am trying to serialize the contents of a Jena
model in JSON. Jena documentation indicates this is possible:
http://jena.apache.org/documentation/io/index.html#formats.However, I
can't find a working example of how to output JSON. The following does not
work:
Model m = ModelFactory.createDefaultModel();
....
//add statements to model [not shown]
....
outputstream = new ByteArrayOutputStream();
model.write(outputStream, "RDF/JSON");
....
It fails with this error:
com.hp.hpl.jena.shared.NoWriterForLangException: RDF/JSON
com.hp.hpl.jena.rdf.model.impl.RDFWriterFImpl.getWriter(RDFWriterFImpl.java:119)
com.hp.hpl.jena.rdf.model.impl.ModelCom.getWriter(ModelCom.java:243)
com.hp.hpl.jena.rdf.model.impl.ModelCom.write(ModelCom.java:277)
..........
Any help in outputting a model as JSON would be much appreciated. Thanks!
Alison
1/ Jena 2.6.4 is quite old and IIRC has no RDF/JSON support, read or write.
2/ The RDF/JSON writer (Jena 2.10.0 and 2.7.*) is accessed via
RDFJSONWriter.write(....)
(this will change quite soon to include model.write(...,"RDF/JSON") but
it is not in 2.10.0)
Andy