【问题标题】:How to serialize nested message with msg-pack in cpp?如何在 cpp 中使用 msg-pack 序列化嵌套消息?
【发布时间】:2017-10-27 15:02:45
【问题描述】:

如何在 cpp 中使用 msg pack 对嵌套在地图中的地图结构进行序列化 - 如下面的消息?:

{"string": "string", "string": {"string": int, "string": int, "string": int} }

【问题讨论】:

    标签: c++ serialization nested maps msgpack


    【解决方案1】:

    我想你想要这个:-

    struct s{
    std::map< std::string, std::string> m;
    std::map< std::string, std::map<std::string, std::int> > l;
    };
    

    【讨论】:

    • 谢谢!这个想法是正确的。为了使它与 msgpack 一起工作,我需要进行一些更改:struct S1 { string subject; vector&lt;unordered_map&lt;string, string&gt;&gt;ref_data; MSGPACK_DEFINE_MAP(subject,ref_data); };
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多