{"id":14652,"library":"json-edm-parser","title":"JSON EDM Streaming Parser","description":"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.","status":"abandoned","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/yaxia/json-edm-parser","tags":["javascript","json","stream","odata","edm","parser"],"install":[{"cmd":"npm install json-edm-parser","lang":"bash","label":"npm"},{"cmd":"yarn add json-edm-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-edm-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const Parser = require('json-edm-parser');","symbol":"Parser","correct":"import { Parser } from 'json-edm-parser';"},{"note":"This is the original and intended way to import the Parser class in CommonJS environments.","symbol":"Parser (CommonJS)","correct":"const Parser = require('json-edm-parser');"}],"quickstart":{"code":"import { Parser } from 'json-edm-parser';\n\nconst p = new Parser();\nlet parsedOutput = {};\n\np.onValue = function (value) {\n  Object.assign(parsedOutput, value);\n};\n\np.onEnd = function () {\n  console.log('Final Parsed Output:');\n  console.log(JSON.stringify(parsedOutput, null, 2));\n};\n\np.onError = function (error) {\n  console.error('Parsing error:', error.message);\n};\n\np.write('{ \"doubleIntNumber\": 12.00,');\np.write('\"doubleNormalNumber\": 1.2,');\np.write('\"doubleLargeNumber\": 12345678901234546789.0000000000000000000000000001,');\np.write('\"int64LargeNumber\": 12345678901234567890123456789}');\np.end();\n\n/* Expected output:\n{\n  \"doubleIntNumber@odata.type\": \"Edm.Double\",\n  \"doubleIntNumber\": \"12.00\",\n  \"doubleNormalNumber\": 1.2,\n  \"doubleLargeNumber@odata.type\": \"Edm.Double\",\n  \"doubleLargeNumber\": \"12345678901234546789.0000000000000000000000000001\",\n  \"int64LargeNumber\": \"12345678901234567890123456789\"\n}\n*/","lang":"javascript","description":"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."},"warnings":[{"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.","message":"This 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.","severity":"breaking","affected_versions":">=0.1.0"},{"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.","message":"The 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.","severity":"deprecated","affected_versions":">=0.1.2"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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()`.","cause":"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.","error":"ERR_REQUIRE_ESM"},{"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.","cause":"This typically happens if `require('json-edm-parser')` is called, but the module either doesn't export a `Parser` class, or is imported incorrectly.","error":"TypeError: Parser is not a constructor"}],"ecosystem":"npm"}