Callidon / sparql-engine

🚂 A framework for building SPARQL query engines in Javascript/Typescript
https://callidon.github.io/sparql-engine
MIT License
97 stars 14 forks source link

Add support for formatting JSON #55

Closed Callidon closed 3 years ago

Callidon commented 3 years ago

This PR adds the functionality to format query results to the official W3C JSON format. The new function JSONFormat can be piped to an existing pipeline of bindings and used as follows

import { JSONFormat } from 'sparql-engine'

// configure your datasets, graphs and the plan builder as usual

let pipeline = builder.execute(/* some SPARQL query */)

// plug-in the json formatter
pipeline = pipeline.pipe(JSONFormat)

// output results
pipeline.subscribe(console.log, console.error, () => console.log('done'))