Skip to content

Commit 4642cd8

Browse files
committed
added section about FLatted VS JSON
1 parent 12359ea commit 4642cd8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ a.push(a);
2424
stringify(a); // [["1","0"],{"a":"0"}]
2525
```
2626

27+
## Flatted VS JSON
28+
29+
As it is for every other specialized format capable of serializing and deserializing circular data, you should never `JSON.parse(Flatted.stringify(data))`, and you should never `Flatted.parse(JSON.stringify(data))`.
30+
31+
The only way this could work is to `Flatted.parse(Flatted.stringify(data))`, as it is also for _CircularJSON_ or any other, otherwise there's no granted data integrity.
32+
33+
Also please note this project serializes and deserializes only data compatible with JSON, so that sockets, or anything else with internal classes different from those allowed by JSON standard, won't be serialized and unserialized as expected.
34+
35+
2736
### New in V1: Exact same JSON API
2837

2938
* Added a [reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Syntax) parameter to `.parse(string, reviver)` and revive your own objects.

0 commit comments

Comments
 (0)