JavaScript JSON-LD Streaming Parser

Dear all,

I had a couple of use cases where I needed to be able to
parse JSON-LD documents to RDF in a streaming way.
To the best of my knowledge, current JavaScript implementations
don’t support streaming parsing, which is why I implemented a streaming parser [1].
Such a parser is especially useful when you need to parse large documents
that don’t fully fit into your memory.

This parser can be configured to be fully spec-compliant.
However, by default, it is not fully compliant for performance reasons.
For example, the parser will by default throw an error
if an @context is found as a non-first entry in an object.

Obviously, a streaming parser will never be as fast as a regular parser for all cases.
However, we still achieve comparable performance for parsing
typical JSON-LD documents, compared to jsonld.js [2].
Currently, this parser is significantly slower for expanded documents,
so I am still looking into optimizing this.

At the moment JSON-LD 1.0 is supported,
but I aim to look into supporting the new 1.1 features in the near future.

More information on how the streaming algorithm works
can be found in the readme [3].

[1] https://github.com/rubensworks/jsonld-streaming-parser.js
[2] https://github.com/rubensworks/jsonld-streaming-parser.js#performance
[3] https://github.com/rubensworks/jsonld-streaming-parser.js#how-it-works

Kind regards,
Ruben Taelman

Received on Friday, 8 February 2019 10:10:48 UTC