SPARQL JSON format compatibility
Is your feature request related to a problem? Please describe. I'd like to display the results of sparql-engine in a YasGUI/YASR component (https://triply.cc/docs/yasgui-api/#yasr) in the browser. For this I need to pass a SPARQL JSON result format (https://www.w3.org/TR/sparql11-results-json/)
Describe the solution you'd like Either directly return bindings in the expected structure, or provide a utility function to convert the original format into a SPARQL JSON result format.
Describe alternatives you've considered None
Additional context Sparnatural : https://sparnatural.eu/
Hi,
We provides an utility function jsonFormat, documented here https://callidon.github.io/sparql-engine/globals.html#jsonformat. It takes as argument the pipeline returned by builder.build(query) and returns a new pipeline which yields results in W3C SPARQL JSON format. It should do the trick for what you want to do.
However, it seems to be missing from the README, which is odd. I will see to add it here, since it's quite a useful feature.
Thanks @Callidon, that's awesome. Useful feature indeed. I feel stupid to ask, but in the browser, how am I supposed to call that function ? I tried but didn't manage to call it properly. I tried
const { HashMapDataset, Graph, PlanBuilder, jsonFormat } = sparqlEngine
and then
console.log(jsonFormat(iterator));
But all I get is jsonFormat is not a function.
jsonFormat returns another pipeline, so you need to subscribe on it