Registry / storage / JASON
library0.1.3jsnpmunverified

JASON is a JSON-like serializer/parser that extends JSON to support objects with methods, cyclic references, Dates, RegExps, Booleans, undefined, and array holes. Current stable version 0.1.3. It uses eval() internally, making it unsafe for untrusted input. Unlike JSON, it preserves object types and allows serialization of complex JavaScript structures, but should only be used in trusted environments. No updates since 2010.

npm install JASON
INSTALL
IMPORT
SIG · JASON
J
JASON
storagejavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

JASON
✓ import JASON from 'JASON'
✗ const JASON = require('JASON')
ESM default import. CommonJS require also works but ESM is preferred.
stringify
✓ import { stringify } from 'JASON'
✗ const stringify = JASON.stringify
Named export available since 0.1.0.
parse
✓ import { parse } from 'JASON'
✗ const parse = JASON.parse
Named export. parse uses eval internally.

Demonstrates stringify and parse of complex objects including methods, dates, undefined, and circular references.

import JASON from 'JASON'; const obj = { name: 'test', date: new Date(), nested: { arr: [1, 2, undefined, 4] }, method: function() { return this.name; }, circular: {} }; obj.circular.self = obj; const str = JASON.stringify(obj); console.log(str); const parsed = JASON.parse(str); console.log(parsed.date instanceof Date); // true console.log(parsed.method()); // 'test' console.log(parsed.circular.self === parsed); // true
Debug
Known issues
gotchaJASON.parse uses eval() internally, executing arbitrary JavaScript from input strings. This can lead to code injection if the input is not from a fully trusted source.
fix
Only use JASON with strings produced by JASON.stringify from a trusted source. Never parse untrusted input.
affects: *
gotchaJASON.stringify may generate code that, when parsed, re-executes side effects if the object contains getters or Proxy traps. The parsed result may not be identical to the original.
fix
Avoid objects with getters or proxies when using JASON. Use a safer serializer like JSON or structured clone for such cases.
affects: *
gotchaJASON does not support Map, Set, Symbol, or WeakMap/WeakRef. These will be lost or cause errors during stringification.
fix
Convert Map/Set to objects or arrays before serialization. Use Symbol.for() keys with caution.
affects: *
gotchaJASON is not a drop-in replacement for JSON. JSON.parse and JSON.stringify will not work with JASON-formatted strings and vice versa.
fix
Always use JASON.parse for JASON strings and JASON.stringify for creating them.
affects: *
Errors
Common errors & fixes
ReferenceError: JASON is not defined
Missing import or require of JASON.
fix
Add 'import JASON from "JASON"' or 'const JASON = require("JASON")' at the top of the file.
Error: Converting circular structure to JSON
Using JSON.stringify on an object with circular references.
fix
Use JASON.stringify instead of JSON.stringify for objects with cycles.
TypeError: obj.method is not a function
JSON.parse discards methods. The parsed object does not have the original's functions.
fix
Use JASON.stringify and JASON.parse to preserve methods.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
54 hits · last 30 days
node
44
Resources
packageJASON ↗
JASON — npm install JASON · libregistry