=============================================
We use a number of persistence mechanisms in our codebase, one of which is storing stringified JSON to disk. The most notable example of this is session persistence (as used by session restore). We use JSON here, because it's a very developer-friendly format to deal with; it's just JavaScript. Being able to persist 'JS' data structures makes it all the more practical to use. However, there are a few downsides to using JSON-to-disk as a full blown persistence mechanism.
- JSON is not streamable; there is (of course) no limit as to how large a blob of JSON may be before it's persisted. When you store large datasets (think: metrics, browser session data), reading it back into memory requires a
JSON.parse(blob)
, which will block the main thread O(size-of-blob)[1] time. In other words: there is no off-main-thread, chunked deserialization mechanism for JSON. - JSON is not compact; there no built-in method to compress s