I am doing some testing on Stardog data retrieval and I am not sure how to address the following:
I have a Stardog database that I query via HTTP URL (http://localhost:5820/myDB/query?query=...
) and Accept = "application/sparql-results+json"
I have created a SPARQL query that looks like this:
select distinct ?p ?childname
where {
?p a ex:Person .
OPTIONAL { ?p ex:hasChild ?child .
?child rdfs:label ?childname . }
}
My problem is that this gives me one object per child, like (note the notation is illustrative):
{ p = XXX
childname = AAA
}
{ p = XXX
childname = BBB
}
....
I can "solve" this with a GROUP_CONCAT but this will just concatenate strings:
{ p = XXX
childname = AAA, BBB, ....
}
I need to obtain the proper JSON structure:
{ p = XXX
{ childname = AAA }
{ childname = BBB }
.....
}
I could of course run two SPARQL queries, one to obtain ?p and another one to obtain the list of ?childname, but this is actually not possible in my situation (without entering in details about why not).
How can I obtain these results with a single URL in JSON?