Closed kanongil closed 5 years ago
Requirements for a new serialization scheme:
deepEqual(obj, parse(stringify(obj)))
when using supported types.BigInt
).I created a "helper" addon for this here: https://github.com/kanongil/granola. While it works 100%, it is in a pre-release state since I might still change the encoded syntax / error handling.
This is intended to replace JSON.stringify()
and JSON.parse()
when handling the envelope
(using Granola.stringify()
and Granola.parse()
). It should work as a drop-in replacement with the advantage of supporting more JS types.
Let me know what you think.
@hueniverse Does it make sense to move it to the hapijs org?
If you want catbox to depend on it, yes, it should be moved.
Possibly as a dev-dependency for catbox itself but probably not. Normal usage would be in engines like catbox-memory
.
Same thing... :-)
Status update?
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
The different engines are responsible for serializing the user provided value before storing it. Most use
JSON.stringify()
for this. Unfortunately, this fails to properly encode some common value types. Most prominentlyDate
,Buffer
,Set
, andMap
objects.Currently, catbox takes a hands-off approach, where the engine is responsible, which causes the engines to support these differently. Eg.
catbox-mongodb
encode to BSON, whilecatbox-memory
has an option to handle top-levelBuffer
objects.This needs to be improved in order to finish #196.
I see two options:
I plan to implement option 2 to keep it flexible. This will require most addons to update their serialization. To simplify this, a new helper addon is created.