我正在运行一个查询,输出从RDF图中检索到的一些JSON结果。结果打印为:
{
"head": {
"vars": [ "uri" , "label" ]
} ,
"results": {
"bindings": [ {
"uri": { "type": "uri" , "value": "Some value" } ,
"label": { "type": "literal" , "xml:lang": "en" , "value": "biomass" }
}
]
}
}
{
"head": {
"vars": [ "uri" , "label" ]
} ,
"results": {
"bindings": [
{
"uri": { "type": "uri" , "value": "some value" } ,
"label": { "type": "literal" , "xml:lang": "en" , "value": "biomass" }
}
]
}
}
我想要做的是将两个结果合并为一个具有不同URI和标签的结果。这是我用来获得结果的代码:
VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (
text, set);
ResultSet results = vqe.execSelect();
/*while(results.hasNext()){
QuerySolution result = results.nextSolution();
RDFNode node = result.get("uri");
test += "\ntest: "+ node +" \n";
}*/
ResultSetFormatter.outputAsJSON(out, results);
}
return out.toString();
//return test;
我使用注释部分只获取显示的URI,但这并不是真正需要的!我需要整个结果集,但合并了。如下所示:
{
"head": {
"vars": [ "uri" , "label" ]
} ,
"results": {
"bindings": [
{
"uri": { "type": "uri" , "value": "Some value" } ,
"label": { "type": "literal" , "xml:lang": "en" , "value": "biomass" }
"uri": { "type": "uri" , "value": "Some other value" } ,
"label": { "type": "literal" , "xml:lang": "en" , "value": "biomass" }
}
]
}
}