Registry / data / jsonld-streaming-parser

jsonld-streaming-parser

JSON →
library5.0.1jsnpmunverified

The `jsonld-streaming-parser` package, currently at version 5.0.1, offers a high-performance and lightweight streaming parser specifically designed for JSON-LD 1.1 documents. It emphasizes full compliance with the JSON-LD 1.1 specification and outputs data in the RDFJS Quad format, ensuring broad compatibility within the RDF ecosystem. A significant advantage of this library is its streaming architecture, which allows it to process extremely large JSON-LD files that would exceed available memory, by emitting RDF triples incrementally as they are parsed. This makes it ideal for handling big data scenarios in the Semantic Web or for real-time Linked Data processing. The project demonstrates active maintenance, with continuous integration badges indicating robust testing and regular updates reflected in its versioning. Its core differentiator lies in its ability to handle both standard and streaming-profile JSON-LD documents efficiently, providing an essential tool for developers working with Linked Data.

npm install jsonld-streaming-parser
INSTALL
IMPORT
SIG · JSONLD-STREAMING-P
J
jsonld-streaming-parser
datajavascriptv5.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JsonLdParser
import { JsonLdParser } from 'jsonld-streaming-parser';
const JsonLdParser = require('jsonld-streaming-parser').JsonLdParser;
The library ships with TypeScript types and supports both ESM and CJS imports, though ESM is the modern preferred pattern for Node.js projects with 'type: module' or bundlers.
Store
import { Store } from 'n3';
The N3.js Store is a common companion for `jsonld-streaming-parser` to manage the parsed RDFJS quads in memory.
promisifyEventEmitter
import { promisifyEventEmitter } from 'event-emitter-promisify';
This helper allows converting event-based stream processing into promise-based async/await syntax for cleaner asynchronous code.

Demonstrates parsing a JSON-LD string using `JsonLdParser` with `streamingProfile` enabled, importing the resulting RDFJS quads into an `N3.Store`, and then querying the stored data. Shows setup for async operations.

import { Store } from 'n3'; import { JsonLdParser } from 'jsonld-streaming-parser'; import { promisifyEventEmitter } from 'event-emitter-promisify'; // Install necessary dependencies: npm install n3 event-emitter-promisify jsonld-streaming-parser async function parseAndStoreJsonLd() { const store = new Store(); // Enable streamingProfile for documents optimized for streaming const parser = new JsonLdParser({ streamingProfile: true }); const jsonLdString = `{ "@context": "https://schema.org/", "@type": "Recipe", "name": "Quick Chocolate Chip Cookies", "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.5", "reviewCount": "120" }, "description": "A classic recipe for delicious, soft chocolate chip cookies." }`; parser.write(jsonLdString); parser.end(); // The parser emits quads which can be imported into an N3 Store await promisifyEventEmitter(store.import(parser)); console.log('Successfully parsed JSON-LD and stored quads:'); for (const quad of store) { console.log(quad.toString()); } // Example of querying the store const cookieName = store.getQuads(null, 'https://schema.org/name', null, null); console.log(`\nFound cookie name: ${cookieName[0]?.object.value}`); } parseAndStoreJsonLd().catch(console.error);
Debug
Known issues
breakingVersion 5.0.0 made JSON-LD 1.1 the default, removing previous options for JSON-LD 1.0. Several parser options like `jsonLdContext` and `rdfjs` were also removed. Direct access to an internal `context` property was replaced by a `context` event.
fix
Ensure your JSON-LD documents are 1.1 compliant or upgrade existing documents. Remove `jsonLdContext` and `rdfjs` options. Migrate any logic relying on the internal `context` property to use the `parser.on('context', ...)` event listener.
affects: >=5.0.0
gotchaTo fully exploit the streaming capabilities for JSON-LD documents optimized with a streaming profile, the `streamingProfile` flag must be explicitly enabled during parser instantiation; it is disabled by default.
fix
Instantiate the `JsonLdParser` with `{ streamingProfile: true }` in its constructor options if your input document benefits from this optimization.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: The 'context' property is not available on JsonLdParser.
Attempting to access `parser.context` directly, which was removed in v5.0.0.
fix
Instead of direct property access, listen to the `context` event emitted by the parser: `parser.on('context', (context) => { /* handle context */ });`.
Error: Invalid JSON-LD syntax at position X.
The input JSON-LD string or stream is malformed, contains syntax errors, or does not conform to the JSON-LD 1.1 specification.
fix
Carefully review your input JSON-LD for correctness. Use a JSON-LD linter or validator (e.g., online JSON-LD playground) to identify specific syntax issues.
Import declaration conflicts with an existing CommonJS require call.
Mixing ES Modules `import` syntax with CommonJS `require` in environments that do not support this hybrid approach, or due to incorrect project configuration (`type: module` in `package.json`).
fix
Standardize your project on either ES Modules (using `import` and setting `"type": "module"` in `package.json`) or CommonJS (using `require`). For new development, ES Modules are generally recommended.
Upgrade
Version history
5.0.1latest on npm
Audit
Dependencies
n3optionalCommonly used for storing and querying RDF/JS quads after parsing.
event-emitter-promisifyoptionalUtility to promisify event emitters, useful for async stream operations.
Agent activity
2 hits · last 30 days
node
2
Resources
jsonld-streaming-parser — npm install jsonld-streaming-parser · libregistry