https://github.com/bioforestchain/bnqkl-jsondryfactory
https://github.com/bioforestchain/bnqkl-jsondryfactory
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bioforestchain/bnqkl-jsondryfactory
- Owner: BioforestChain
- Created: 2023-06-09T10:18:02.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-10T03:08:04.000Z (about 3 years ago)
- Last Synced: 2024-03-15T10:12:51.589Z (over 2 years ago)
- Language: TypeScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSON dry Factory
create an `JSON` instance, and registered isolated serialization/deserialization handlers for custom classes.
Importantly, it is possible that a Class is registered with multiple JSON-dry instances. Will not affect each other.
This is very important. For example, during process communication, different modules may need to register a specific serialization deserialization scheme for the Error object. Use this library to ensure that this Error class can serve multiple modules at the same time.
DEMO
```ts
import { JSONDryFactory } from "json-dry-factory";
const jsonFac = new JSONDryFactory("test1");
const json = jsonFac.stringify({
a: "QAQ",
r: /z\d([1-z]+?)/g,
mix: { '4': 3, o: new Date(), 0: "1" },
e: new Error('cccc'),
deep: {
a: {
b: {
x: /44/,
c: {
m: "ccc",
s: /cc/
}
},
xx: "432cc1",
x: 4321,
bb: /cf/
}
}
});
console.log(json);
const obj = jsonFac.parse(json);
console.log('-----------------------');
console.log(obj);
```