Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPARQL JSON format compatibility #79

Open
tfrancart opened this issue Feb 8, 2023 · 3 comments
Open

SPARQL JSON format compatibility #79

tfrancart opened this issue Feb 8, 2023 · 3 comments

Comments

@tfrancart
Copy link

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/

@Callidon
Copy link
Owner

Callidon commented Feb 8, 2023

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.

@tfrancart
Copy link
Author

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.

@Callidon
Copy link
Owner

Callidon commented Feb 8, 2023

jsonFormat returns another pipeline, so you need to subscribe on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants