https://github.com/acorcutt/jxo
Make almost any JavaScript Object JSON safe.
https://github.com/acorcutt/jxo
javascript json object stringify
Last synced: 5 months ago
JSON representation
Make almost any JavaScript Object JSON safe.
- Host: GitHub
- URL: https://github.com/acorcutt/jxo
- Owner: acorcutt
- Created: 2021-10-27T22:36:16.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-30T15:50:39.000Z (over 4 years ago)
- Last Synced: 2025-10-07T23:25:30.451Z (8 months ago)
- Topics: javascript, json, object, stringify
- Language: JavaScript
- Homepage:
- Size: 81.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 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
```javascript
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](test.js) for more examples.
---
## TODO
- [ ] Better instructions
- [ ] More examples
- [ ] Better fallback handing with customisation
- [ ] Validate the custom types
- [ ] Encoders for typed arrays
- [ ] Buffers