Registry / serialization / json-edm-parser

json-edm-parser

JSON →
library0.1.2jsnpmunverified

json-edm-parser is a streaming JSON parser designed for Node.js environments. Its primary function is to interpret and preserve Entity Data Model (EDM) type information, making it compatible with OData specifications. Specifically, it addresses the common issue where standard JSON parsers might misinterpret numbers (e.g., `12.00` as an integer) by explicitly adding an `"<property>@odata.type": "Edm.Double"` member to objects for values that represent doubles but might otherwise be seen as integers. The package is currently at version 0.1.2 and has not seen updates in approximately nine years, indicating it is no longer actively maintained. Its release cadence was minimal, and its niche focus on OData EDM type preservation within a streaming context differentiates it from general-purpose JSON parsers.

npm install json-edm-parser
INSTALL
IMPORT
SIG · JSON-EDM-PARSER
J
json-edm-parser
serializationjavascriptv0.1.2
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.

Parser
import { Parser } from 'json-edm-parser';
const Parser = require('json-edm-parser');
While the original library uses CommonJS `require()`, modern Node.js applications typically use ESM. Directly importing this CJS-only package into an ESM module may require careful configuration or a wrapper.
Parser (CommonJS)
const Parser = require('json-edm-parser');
This is the original and intended way to import the Parser class in CommonJS environments.

This example demonstrates how to use the streaming parser to process a JSON string, capturing the `onValue` events and aggregating the parsed output. It highlights how the parser adds `@odata.type` properties for specific number formats to preserve OData EDM type information.

import { Parser } from 'json-edm-parser'; const p = new Parser(); let parsedOutput = {}; p.onValue = function (value) { Object.assign(parsedOutput, value); }; p.onEnd = function () { console.log('Final Parsed Output:'); console.log(JSON.stringify(parsedOutput, null, 2)); }; p.onError = function (error) { console.error('Parsing error:', error.message); }; p.write('{ "doubleIntNumber": 12.00,'); p.write('"doubleNormalNumber": 1.2,'); p.write('"doubleLargeNumber": 12345678901234546789.0000000000000000000000000001,'); p.write('"int64LargeNumber": 12345678901234567890123456789}'); p.end(); /* Expected output: { "doubleIntNumber@odata.type": "Edm.Double", "doubleIntNumber": "12.00", "doubleNormalNumber": 1.2, "doubleLargeNumber@odata.type": "Edm.Double", "doubleLargeNumber": "12345678901234546789.0000000000000000000000000001", "int64LargeNumber": "12345678901234567890123456789" } */
Debug
Known issues
breakingThis package is a CommonJS module (`require()`) and does not natively support ES Modules (`import`). Direct `import` statements in pure ESM environments will result in errors.
fix
For ESM projects, use dynamic import `import('json-edm-parser')` or create a CJS wrapper module. Alternatively, ensure your build system can handle CJS modules in an ESM context.
affects: >=0.1.0
deprecatedThe package has not been updated in approximately nine years (last published 9 years ago). It is considered abandoned and may have unaddressed bugs, security vulnerabilities, or compatibility issues with newer Node.js versions.
fix
Consider using more modern and actively maintained JSON parsers, especially if OData EDM type handling is not strictly required or can be implemented with a post-processing step.
affects: >=0.1.2
gotchaThe parser handles large numbers by converting them to strings to preserve precision, which can be unexpected if strict number typing is required. It also explicitly adds `@odata.type` properties, modifying the original JSON structure.
fix
Be aware of the output format. If you need numbers in a specific format (e.g., BigInt) or prefer a pure JSON output without OData type annotations, custom post-processing will be necessary.
affects: >=0.1.0
gotchaThe package does not ship with TypeScript type definitions (`.d.ts` files). Using it in a TypeScript project will result in type errors unless custom declarations are provided.
fix
Create a `json-edm-parser.d.ts` file in your project or install `@types/json-edm-parser` if it ever becomes available (unlikely given abandonment). For basic usage, `declare module 'json-edm-parser';` can suppress errors, but without type safety.
affects: >=0.1.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to `require()` a package that is ESM-only, or more commonly, trying to `import` a CJS-only package like `json-edm-parser` in an ESM module.
fix
If in an ESM project, use `const Parser = (await import('json-edm-parser')).Parser;` or ensure your `package.json` specifies `"type": "commonjs"` if you intend to use `require()`.
TypeError: Parser is not a constructor
This typically happens if `require('json-edm-parser')` is called, but the module either doesn't export a `Parser` class, or is imported incorrectly.
fix
Ensure `const Parser = require('json-edm-parser');` is used in a CommonJS context. If using a transpiler or bundler, verify it handles CJS modules correctly.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources