fix: return W3C standard JSON format for SPARQL ASK queries

ASK queries were returning raw JavaScript booleans (true/false) instead of
the W3C SPARQL 1.1 standard JSON format {"head": {}, "boolean": true/false}.

This fix uses QueryResultsSerializer to properly format ASK query results,
ensuring compatibility with standards-compliant SPARQL applications and
consistency with SELECT/CONSTRUCT query behavior.

The issue was in ng-verifier/src/request_processor.rs where
AppResponseV0::True/False were returned instead of a properly
serialized QueryResult.

Fixes: Non-standard ASK query responses
Reference: https://www.w3.org/TR/sparql11-results-json/
fix/sparql-ask-json-format
Cameron Sajedi 2 days ago
parent ca72009ae7
commit 8803c63946
  1. 11
      ng-verifier/src/request_processor.rs

@ -294,11 +294,12 @@ impl Verifier {
))
}
QueryResults::Boolean(b) => {
if b {
AppResponse::V0(AppResponseV0::True)
} else {
AppResponse::V0(AppResponseV0::False)
}
// serialize boolean results as standard SPARQL JSON format
let serializer = QueryResultsSerializer::from_format(QueryResultsFormat::Json);
let result = serializer
.serialize_boolean_to_write(Vec::new(), b)
.map_err(|_| "QueryResult serializer error")?;
AppResponse::V0(AppResponseV0::QueryResult(result))
}
QueryResults::Graph(quads) => {
let mut results = vec![];

Loading…
Cancel
Save