{"id":13405,"library":"jsonld-streaming-parser","title":"JSON-LD Streaming Parser","description":"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.","status":"active","version":"5.0.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/rubensworks/streaming-jsonld-parser.js","tags":["javascript","json","linked data","semantic web","json-ld","jsonld","rdf","rdfjs","streaming","typescript"],"install":[{"cmd":"npm install jsonld-streaming-parser","lang":"bash","label":"npm"},{"cmd":"yarn add jsonld-streaming-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add jsonld-streaming-parser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Commonly used for storing and querying RDF/JS quads after parsing.","package":"n3","optional":true},{"reason":"Utility to promisify event emitters, useful for async stream operations.","package":"event-emitter-promisify","optional":true}],"imports":[{"note":"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.","wrong":"const JsonLdParser = require('jsonld-streaming-parser').JsonLdParser;","symbol":"JsonLdParser","correct":"import { JsonLdParser } from 'jsonld-streaming-parser';"},{"note":"The N3.js Store is a common companion for `jsonld-streaming-parser` to manage the parsed RDFJS quads in memory.","symbol":"Store","correct":"import { Store } from 'n3';"},{"note":"This helper allows converting event-based stream processing into promise-based async/await syntax for cleaner asynchronous code.","symbol":"promisifyEventEmitter","correct":"import { promisifyEventEmitter } from 'event-emitter-promisify';"}],"quickstart":{"code":"import { Store } from 'n3';\nimport { JsonLdParser } from 'jsonld-streaming-parser';\nimport { promisifyEventEmitter } from 'event-emitter-promisify';\n\n// Install necessary dependencies: npm install n3 event-emitter-promisify jsonld-streaming-parser\n\nasync function parseAndStoreJsonLd() {\n  const store = new Store();\n  // Enable streamingProfile for documents optimized for streaming\n  const parser = new JsonLdParser({ streamingProfile: true });\n\n  const jsonLdString = `{\n    \"@context\": \"https://schema.org/\",\n    \"@type\": \"Recipe\",\n    \"name\": \"Quick Chocolate Chip Cookies\",\n    \"aggregateRating\": {\n      \"@type\": \"AggregateRating\",\n      \"ratingValue\": \"4.5\",\n      \"reviewCount\": \"120\"\n    },\n    \"description\": \"A classic recipe for delicious, soft chocolate chip cookies.\"\n  }`;\n\n  parser.write(jsonLdString);\n  parser.end();\n\n  // The parser emits quads which can be imported into an N3 Store\n  await promisifyEventEmitter(store.import(parser));\n\n  console.log('Successfully parsed JSON-LD and stored quads:');\n  for (const quad of store) {\n    console.log(quad.toString());\n  }\n  // Example of querying the store\n  const cookieName = store.getQuads(null, 'https://schema.org/name', null, null);\n  console.log(`\\nFound cookie name: ${cookieName[0]?.object.value}`);\n}\n\nparseAndStoreJsonLd().catch(console.error);","lang":"typescript","description":"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."},"warnings":[{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Instantiate the `JsonLdParser` with `{ streamingProfile: true }` in its constructor options if your input document benefits from this optimization.","message":"To 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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Instead of direct property access, listen to the `context` event emitted by the parser: `parser.on('context', (context) => { /* handle context */ });`.","cause":"Attempting to access `parser.context` directly, which was removed in v5.0.0.","error":"TypeError: The 'context' property is not available on JsonLdParser."},{"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.","cause":"The input JSON-LD string or stream is malformed, contains syntax errors, or does not conform to the JSON-LD 1.1 specification.","error":"Error: Invalid JSON-LD syntax at position X."},{"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.","cause":"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`).","error":"Import declaration conflicts with an existing CommonJS require call."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}