I've seen the answer on How to return SPARQL results in JSON-LD?, but it's not satisfying/working. I used the JSON-LD Java Integration for Sesame, as well as the standalone version.
What I want to achieve: Send a SPARQL CONSTRUCT query to a SPARQL endpoint via Blazegraph RemoteRepository (based on Sesame/SAIL), get an RDF result, serialize that RDF to JSON-LD. The RDF result works perfectly fine.
The problem is, that the following code (with Sesame) is producing exactly no output:
StringWriter sw = new StringWriter();
final RDFWriter writer = Rio.createWriter( RDFFormat.JSONLD, sw );
//writer.getWriterConfig().set( JSONLDSettings.JSONLD_MODE, JSONLDMode.COMPACT );
GraphQueryResult queryResults;
Rio.write(QueryResults.asModel(queryResults), writer);
I also used a conversion to a Jena internal model, because I know that the Jena JSON-LD output worked fine in another side project of mine. Unfortunately, the same approach doesn't work for a conversion to Jena.
My code with a Sesame to Jena Adapter:
while(queryResults.hasNext()) {
JenaUtils.asJenaStatement();
}
StringWriter sw = new StringWriter();
// JenaUtils.getModel() returns the Jena model with the added statements above
RDFDataMgr.write( sw, JenaUtils.getModel(), RDFFormat.JSONLD );
What can I do now?