Skip to content
/ jxo Public

Make almost any JavaScript Object JSON safe.

Notifications You must be signed in to change notification settings

acorcutt/jxo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JxO

Make almost any JavaScript Object JSON safe for use with JSON.stringify and JSON.parse. With support for circular references, Maps, Sets, Typed Arrays, Symbols and custom types.

Installation

npm install jxo
pnpm add jxo
yarn add jxo

Basic Usage

Use as a replacement for JSON.stringify and JSON.parse

import { JxO } from 'jxo';

const JXO = new JxO();

const obj = {
  supports: new Set([NaN, Infinity, undefined, new Date(), new Map([['and', 'more']])]),
};
obj.self = obj;

const str = JXO.stringify(obj);

const res = JXO.parse(str);

Examples

See test.js for more examples.


TODO

  • Better instructions
  • More examples
  • Better fallback handing with customisation
  • Validate the custom types
  • Encoders for typed arrays
  • Buffers

About

Make almost any JavaScript Object JSON safe.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published