https://github.com/capaj/refserialize
a utility for serializing/deserializing POJOs with object references
https://github.com/capaj/refserialize
Last synced: 12 months ago
JSON representation
a utility for serializing/deserializing POJOs with object references
- Host: GitHub
- URL: https://github.com/capaj/refserialize
- Owner: capaj
- License: mit
- Created: 2016-11-21T16:57:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-28T00:36:45.000Z (over 9 years ago)
- Last Synced: 2025-07-03T22:03:13.117Z (about 1 year ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# refserialize
Serialize your POJO objects and retain reference equality between multiple references to the same objects
## Install
```
npm i refserialize
```
Example:
```javascript
const refserialize = require('refserialize')
var a = {b: 1}
var o = {
c: a,
d: a
}
const str = refserialize.stringify(o)
const parsed = refserialize.parse(str)
parsed.c === parsed.d // true
```
Keep in mind that this only works inside one parent object. If you call serialize twice on two different objects, which have some common reference, this reference will not be resolved into a single object. You really need to put your two objects into one parent object.
Also beware of the performance. I have not tested this with large objects, but expect it to be quite slow.