msgpack-d
msgpack-d copied to clipboard
Pack empty arrays as zero-length arrays
It is point at issue, but it seems like it is better in terms of compatibility with other languages. For example, msgpack-c provides default adapters for vectors and strings that throw an exception in case of nil value deserialization. It is ok to send c++ empty std::vectors, std::strings, std::vectors of std::strings, etc, packed by default to the dlang application and get dlang empty strings, arrays[], etc, but not the other way around. That's why communication between dlang-app and cpp-app via msgpack is complicated. Also python implementation of msgpack produces zero-length arrays. In addition, zero-length arrays are serialized into one byte as well as nil value.
Thanks!
But this breaks backward compatibility. I have a plan to implement new spec and this is a chance to merge this PR. Please wait.
I'm reconsider this issue.
In C++, std::vector
and other containers are struct so they can't handle nil
properly.
But In Java, C# or other languages, they can handle nil
for container object.
So this change is not good for almost languages.
There are several approaches to resolve this issue.
- msgpack-c supports
nil
in containers. Maybe returns uninitialized container? - msgpack-d provides
handleNilAsZeroSizeContainer
like parameter to switch behaviours.