Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swlws/json-ify
javascript object serialization
https://github.com/swlws/json-ify
Last synced: about 1 month ago
JSON representation
javascript object serialization
- Host: GitHub
- URL: https://github.com/swlws/json-ify
- Owner: swlws
- License: mit
- Created: 2023-06-06T00:22:18.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-06-22T14:31:19.000Z (over 1 year ago)
- Last Synced: 2024-11-06T15:52:11.454Z (3 months ago)
- Language: TypeScript
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# JSONify
a json serialization lib, supported data type:
- number
- string
- boolean
- date
- regexp
- function, arrow function
- map
- set# usage
```ts
import { stringify, parse } from "@swl/json-ify";const obj = {
a: null,
b: undefined,
c: 100,
d: "dd",
e: true,
f: {},
g: [],
h: new Date(),
i: new Set([11, 22, 33, new Set([55, 66, 77])]),
j: new Map([
["age", { age: 100 }],
[{ age: 100 }, "age"],
]),
k: function () {
return this.a;
},
l: () => {
return "arrow function";
},
m: /abc/g,
n: new RegExp("abc", "img"),
};const rt = stringify(obj, 2);
console.log(rt);
const rt2 = parse(rt);
console.log(rt2);
```