qlever
qlever copied to clipboard
JSON SPARQL result sorted alphabeticly by variable name
I am building a Superset/SPARQL connector experimenting with QLever. I have observed that the JSON response to a SPARQL query are in alphabetically ordered column which is a problem for me. Why are the json value predicates not in the same order as the one in the SELECT part of the query ?
Is there a parameter to fix this ?
This new project home https://github.com/fbelleau/superset4sparql
for example
select ?t (count(?s) as ?c)
where {
?s a ?t .
}
group by ?t
order by ?t
returns
{
"head": {
"vars": [
"t",
"c"
]
},
"results": {
"bindings": [
{
"c": {
"datatype": "http://www.w3.org/2001/XMLSchema#int",
"type": "literal",
"value": "253203"
},
"t": {
"type": "uri",
"value": "http://bio2rdf.org/bibtex#Article"
}
it should respect SELECT variable order ?t before ?c
{
"head": {
"vars": [
"t",
"c"
]
},
"results": {
"bindings": [
{
,
"t": {
"type": "uri",
"value": "http://bio2rdf.org/bibtex#Article"
},
"c": {
"datatype": "http://www.w3.org/2001/XMLSchema#int",
"type": "literal",
"value": "253203"
},
Thanks for your interest in QLever, I will have a look at your project when I find the time for it (probably after the easter holidays)
Concerning your question:
The array vars
is in order (first t
then c
). The individual entries of the bindings
array are objects
(dictionaries/hash maps) that have no ordering but are accessed via the corresponding variable
(e.g. bindings[1]["c"]
). Any JSON deserializer should handle these entries independently of the order.
I can see if we can configure our JSON serializer to print these results in order, but I would be interested in knowing how you use these results in a way that makes a difference.
Best regards Johannes