C
C
Caretaker2019-08-20 22:40:40
Node.js
Caretaker, 2019-08-20 22:40:40

Are there quick ways to serialize/deserialize objects?

Greetings.
There is a "basic" way to serialize/deserialize objects - a JSON string. But it is far from being the fastest and with rather large objects it spends a lot of resources (primarily temporary).
Is there some method of fast "packing / unpacking" of objects into a binary version (for example), which would be both "more compact" and the algorithm itself is faster than working with JSON operands?
PS. I’ll clarify right away - the structure of objects is indefinite and the length of any fields / subfields / subfields, etc. absolutely unknown, i.e. it will not work to drive blocks into the buffer "bit by bit" in a consistent order.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ihor Bratukh, 2019-08-21
@BRAGA96

msgpack
bson

V
Vladimir S, 2019-08-21
@hePPer

The only option in the current realities is to find a faster "packing / unpacking" option + reduce the amount of data transferred ...

there are two options - universal and fast, options in most cases are not compatible. Therefore
, the most nimble is custom. and the more narrowly focused and not more universal it will be, the faster it will work.

V
Vitaly, 2019-08-21
@vshvydky

as an option to use the new version of node 12.9
with a patch note, something pleasant is written:
Updated V8 to 7.6.303.29 (Michaël Zasso) #28955.
Improves the performance of various APIs such as JSON.parse and methods called on frozen arrays.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question