https://github.com/rickyli79/rich-json
serialize and deserialize rich javascript data types, suport reference data.
https://github.com/rickyli79/rich-json
circular-reference clone json rich-type
Last synced: about 1 year ago
JSON representation
serialize and deserialize rich javascript data types, suport reference data.
- Host: GitHub
- URL: https://github.com/rickyli79/rich-json
- Owner: RickyLi79
- License: mit
- Created: 2024-02-29T15:08:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-22T18:05:16.000Z (about 2 years ago)
- Last Synced: 2025-03-02T03:23:41.177Z (about 1 year ago)
- Topics: circular-reference, clone, json, rich-type
- Language: TypeScript
- Homepage: https://rickyli79.github.io/rich-json/
- Size: 705 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @rickyli79/rich-json
serialize and deserialize rich javascript data types, suport reference data.
## install
```
npm install @rickyli79/rich-json
```
## usage
### supported runtime
- NodeJS
- Browser
### stringify
```typescript
import RichJson from '@rickyli79/rich-json'
// const RichJson = require('@rickyli79/rich-json');
const complexObj_origin = { key: 'any supported data types' };
const rJson:string = RichJson.stringify(complexObj_origin);
// todo: save rJson to file;
```
### parse
```typescript
import RichJson from '@rickyli79/rich-json'
const rJson:string = getRichJsonText();
const complexObj = RichJson.parse(rJson);
```
### clone
```typescript
import RichJson from '@rickyli79/rich-json'
const complexObj_origin = { key: 'any supported data types' };
const complexObj = RichJson.clone(complexObj_origin);
assert.notStrictEqual(complexObj, complexObj_origin);
```
## supported data types
- primitive
- null
- undefined
- bigint
- number
- normal
- `NaN`
- `-0`
- `Number.EPSILON`
- `Number.MAX_SAFE_INTEGER`
- `Number.MIN_SAFE_INTEGER`
- `Number.NEGATIVE_INFINITY`
- `Number.POSITIVE_INFINITY`
- function
- function
- async function
- arrow function
- async arrow function
- object
- `URL`
- `Date`
- `RegExp`
- `Set`
- `Map`
- `Error` ( with `message` only, ~~without `stack`~~ )
- Buffer like
- `Buffer` ***in NodeJs***
- `Int8Arrany`, `Uint16Array`, `Uint32Array` ...and more
- ~~NOT support `Blob`~~
- `WrapRunner` class
- customer serializers
- reference
- reference to same object
- circular reference
> including reference in `Set` and `Map`, and `WrapRunner` class or `customer serializers`
## unittest
- Report: https://rickyli79.github.io/rich-json/
- [unittest files](https://github.com/RickyLi79/rich-json/tree/main/test)