You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to pack a map into a msgpack object and serialize it.
This is the code I'm using:
msgpack::type::variant ObjectNode::toMsgPack() const {
std::map<msgpack::type::variant, msgpack::type::variant> packed_map;
for (const auto &pair: children) {
packed_map.insert({std::move(msgpack::type::variant(pair.first)), std::move(pair.second->toMsgPack())});
}
return msgpack::type::variant(std::move(packed_map));
}
At smaller map sizes, everything seems to work fine. However, I've noticed that the moment I try to pack a map larger than 15 elements -> which changes the internal type from fixmap to map16 if I understand correctly -> the output is incorrect.
^The output when I tried using the json->msgpack converter from msgpack's site. (correct)
As you can see, it appears that msgpack::pack() in my case mishandles the length of the map, putting it at 8208(2^13+16?) instead of 16.
I've spent a good while thinking about it & trying to look through the docs, but I've no idea what could cause this.
To be clear, mpgpack-c itself still seems to be able to unpack the map just fine, even if it doesn't seem to conform to the format spec. However I'm slightly worried about whether this would be transferable between various environments, hence - if possible - I'd like to address it.
Would anyone be able to point me in the right direction?
I'd be extremely grateful^^
The text was updated successfully, but these errors were encountered:
Hey!
I'm trying to pack a map into a msgpack object and serialize it.
This is the code I'm using:
At smaller map sizes, everything seems to work fine. However, I've noticed that the moment I try to pack a map larger than 15 elements -> which changes the internal type from fixmap to map16 if I understand correctly -> the output is incorrect.
I tried dissecting the output in hex:
(the correct output from a 15 elements long map)
Output after adding a new key->value pair. (incorrect)
^The output when I tried using the json->msgpack converter from msgpack's site. (correct)
As you can see, it appears that msgpack::pack() in my case mishandles the length of the map, putting it at 8208(2^13+16?) instead of 16.
I've spent a good while thinking about it & trying to look through the docs, but I've no idea what could cause this.
To be clear, mpgpack-c itself still seems to be able to unpack the map just fine, even if it doesn't seem to conform to the format spec. However I'm slightly worried about whether this would be transferable between various environments, hence - if possible - I'd like to address it.
Would anyone be able to point me in the right direction?
I'd be extremely grateful^^
The text was updated successfully, but these errors were encountered: