[msgpack][JIRA] Created: (MSGPACK-82) Size-less, delimited "arrays" to ease object serialization

17 views
Skip to first unread message

Michael Neumann (JIRA)

unread,
Dec 25, 2012, 3:52:11 PM12/25/12
to msgpa...@googlegroups.com
Size-less, delimited "arrays" to ease object serialization
----------------------------------------------------------

Key: MSGPACK-82
URL: http://jira.msgpack.org/browse/MSGPACK-82
Project: MessagePack
Issue Type: New Feature
Components: Specification
Reporter: Michael Neumann
Assignee: FURUHASHI Sadayuki
Priority: Minor


I am the author of an alternative msgpack implementation of C++ and Ruby [1] as well as for Rust [1]. We are using in-house msgpack to serialize C++ objects. We serialize objects as arrays, but the ugly thing doing so is that we have to count the fields.

packer.pack_array(10);
packer << field_1;
packer << field_2;
...

This is pretty ugly IMHO as I always have to count the number of fields. In my msgpack implementation [3] I have used the reserved bytes 0xc4 and 0xc5 as "array" delimiters in this way:

0xc4 item0, ..., itemN 0xc5

This is pretty easy to implement btw. But we are not using this feature as it would not allow us to load the msgpack data from another language. I know that adding something to the specification will make many implementations "invalid", so maybe it could be added as an "extension" to the spec? People could implement it if they like it, but you should not depend on it when you really are concerned about interoperability.

Btw, the same could be applied to Maps, i.e. open (size-less) maps.

I think it could also help to distinguish between Arrays and Objects. When you serialize an Array you always know it's size at runtime, while when you serialize an Object there is no number of fields directly accessible, so the programmer has to specify it. So my proposal is to use 0xc4 and 0xc5 for serializing Objects only.

Regards,

Michael

[1]: https://github.com/mneumann/MessagePack
[2]: https://github.com/mneumann/rust-msgpack
[3]: https://github.com/mneumann/MessagePack/blob/master/include/MessagePack.h

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply all
Reply to author
Forward
0 new messages