ludocode / mpack

MPack - A C encoder/decoder for the MessagePack serialization format / msgpack.org[C]
MIT License
521 stars 82 forks source link

Copy element from node API to write API #84

Closed VersusQ closed 2 years ago

VersusQ commented 3 years ago

I need some help. Because I can't find way to solve my problem.

I need to copy nested map (from another map) into new mpack as is. Could I do it somehow in your library?

Or simpler case. Could I write into new map pre-serialized element? I serialize nested map once and will be write it in many new map as ready element.

ludocode commented 2 years ago

It's possible to write a pre-serialized element with mpack_write_object_bytes(). Note that you must write exactly one element including all its contents with this for the write tracking to work properly. If you're writing multiple elements in one call, a workaround might be to call it additional times with zero length for the additional elements.