3
如何将JENA ResultSet存储为JSON格式的字符串?我目前只能够将ResultSet输出到System.out控制台,但我无法将其保存到java字符串中。这是我在其中一个例子:我希望能够到JSON变量发送到其他的方法来对它进行一些工作如何将JENA Sparql查询结果集保存为JSON?
QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, query);
ResultSet results = qexec.execSelect();
// the following prints out JSON in the System.out console:
ResultSetFormatter.outputAsJSON(System.out, results);
// but how do I save it as a String?
// ie.
String json = ResultSetFormatter.outputAsJSON(System.out, results);
// obviously that doesn't work, but how would one get the equivalent working version?
。
在此先感谢!