https://github.com/mys1024/json-referencable
Keep references in JSON.
https://github.com/mys1024/json-referencable
json ref refrence
Last synced: about 1 year ago
JSON representation
Keep references in JSON.
- Host: GitHub
- URL: https://github.com/mys1024/json-referencable
- Owner: mys1024
- License: mit
- Created: 2022-09-19T14:40:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-27T14:28:55.000Z (over 3 years ago)
- Last Synced: 2025-02-23T04:07:05.650Z (about 1 year ago)
- Topics: json, ref, refrence
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/json-referencable
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# json-referencable
Keep references in JSON.
# Usage
```typescript
import * as JSONR from 'json-referencable'
const foo = { id: 'foo' }
const bar = { id: 'bar' }
foo.next = bar
bar.next = foo
const json = JSONR.stringify(foo) // '{"refs":{"_ref_0":{"id":"foo","next":"_ref_1"},"_ref_1":{"id":"bar","next":"_ref_0"}},"root":"_ref_0"}'
const parsedFoo = JSONR.parse(json) // `parsedFoo` is structurally the same as `foo`
parsedFoo === parsedFoo.next.next // true
```
## License
MIT