0

I am running a query that outputs some JSON results retrieved from RDF graphs. Results are printed as:

{
  "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" }
                        }
                    ]
           }
 }

What I would like to do is to merge both results into one with different URIs and labels. This is the code I use to get the results:

        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;

I use the commented part to get only the URIs displayed, but that is not really what is needed! I need the whole result set, but merged. Like the following :

{

 "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" }

  }

]

  }

}
4
  • Please add the desired output format based on the examples above.
    – Smutje
    Apr 30, 2014 at 12:43
  • @Smutje I just did! thanks
    – callback
    Apr 30, 2014 at 12:50
  • You can't have two nodes with same name at same level. Apr 30, 2014 at 12:55
  • @RahulBobhate the name was just arbitrary! it could be anything!
    – callback
    Apr 30, 2014 at 12:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.