I am doing some testing on Stardog data retrieval and I am not sure how to address the following:
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
....
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).
Thanks.