msgpack-c icon indicating copy to clipboard operation
msgpack-c copied to clipboard

MSGPACK_DEFINE_MAP with base classes

Open KoHcoJlb opened this issue 7 years ago • 3 comments

Shouldn't it pack base class fields into the map root?

KoHcoJlb avatar May 25 '18 09:05 KoHcoJlb

Could you elaborate the question? In addition, if you post a complete and minimal code that describes the issue, it is very helpful. You can use Wandbox for this. See https://wandbox.org/permlink/xIejfhw3v2y2SkBK

Modify code, click "Run", then click "Share", you can get updated permalink on your address bar.

redboltz avatar Jun 07 '18 06:06 redboltz

In your code snippet why derived is serialized to {"base":{"i":10},"j":20} instead of {"i":10,"j":20}?

KoHcoJlb avatar Jun 07 '18 10:06 KoHcoJlb

msgpack-c class adaptor is mapped to MAP or ARRAY. It is a design choice.

It is not all reason for that, but the base class and derived class could have the same name variables. Here is the example: https://wandbox.org/permlink/fs6iOWPCmT0qSEpS

redboltz avatar Jun 07 '18 12:06 redboltz