sparqljenasemantic-webapache-jena

Convert a Jena ResultSet to Model


I'm trying to convert a ResultSet to a Model in Apache Jena 3.0.

Previously I used the

ResultSetFormatter.toModel function, but this seems to have been removed.

What's the best way currently to get a Model (for serialization to JSON-LD and RDF/XML) of the ResultSet?


Solution

  • RDFOutput.toModel

    ResultSetFormatter operations were deprecated in jena 2.13.0 with placeholders left behind and javadoc referring to RDFOutput.

    Example

        ResultSet results = ResultSetFactory.fromJSON(in);
        Model model = RDFOutput.encodeAsModel(results);