You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Dimov, Stefan" <st...@sap.com> on 2017/04/25 19:44:53 UTC

How can I get non-flattened JSON SPARQL response

Hi all,

I have the following JSON-LD structure loaded in a named graph:

{
    "@context": {"@vocab": "http://ao.com/g/"},
    "@id" : "http://ao.com/uc/example",
    "propOf": {
        "prop": {
            "term" : {"o#0" : "w#0","o#1" : "w#1",
                "o#2" : "w#2",
                "o#3" : "w#4"
             }
        },"obj": "w#5"
    }
}

When I request it with:

DESCRIBE ?s
{
  GRAPH <http://ao.com/namedGraph/g> { ?s ?p0 ?o0 }
  FILTER (STR(?s) = "http://ao.com/uc/example")
}

I get the following response:

<http://ao.com/uc/example>
        <http://ao.com/g/propOf>
                [ <http://ao.com/g/obj>   "w#5" ;
                  <http://ao.com/g/prop>  [ <http://ao.com/g/term>
                                    [ <http://ao.com/g/o#0>  "w#0" ;
                                      <http://ao.com/g/o#1>  "w#1" ;
                                      <http://ao.com/g/o#2>  "w#2" ;
                                      <http://ao.com/g/o#3>  "w#4"
                                    ] ]
                ] .

When I add to the URL ?output=json or json-ld or json-rdf I get a correct JSON response (as expected), but this JSON is flattened into array.

Is it possible to get a JSON response, which is structured, like the one above? Basically, I need some JSON response that is similar to the input. How can I have it?

Regards,
Stefan