SPARQL results in JSON

2 views
Skip to first unread message

justforthe...@gmail.com

unread,
Jul 1, 2014, 4:06:04 PM7/1/14
to sta...@clarkparsia.com
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 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 this results with a single URL in JSON?

Thanks.

Mike Grove

unread,
Jul 7, 2014, 10:08:42 AM7/7/14
to stardog
You're best off doing separate queries, or transforming the JSON returned as query results into the format your application requires.

Cheers,

Mike
 

Thanks.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

justforthe...@gmail.com

unread,
Jul 7, 2014, 10:47:07 AM7/7/14
to sta...@clarkparsia.com
Thanks Mike, - I assume there is no way to obtain the results in the desired structure then.
Reply all
Reply to author
Forward
0 new messages