Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用MsgPack而不是使用MsgPack Cli使用Json序列化c#对象_C#_Json.net_Msgpack - Fatal编程技术网

使用MsgPack而不是使用MsgPack Cli使用Json序列化c#对象

使用MsgPack而不是使用MsgPack Cli使用Json序列化c#对象,c#,json.net,msgpack,C#,Json.net,Msgpack,我试图在c中使用MsgPack实现一种JSON序列化# 我使用的是MsggPack CLI,您可以在 根据msgpack.org文档,序列化模型 {"model":"message"} 六边形 81 a5 6d 6f 64 65 6c a7 6d 65 73 73 61 67 65 但是当试图在c#中做同样的事情时(当然是用一种幼稚的方法) 我得到 91 a7 6d 65 73 73 61 67 65 其中跳过了“模型”名称 如何修复它?终于找到了简单的方法。 根据文档,序列化格式默认为

我试图在c中使用MsgPack实现一种JSON序列化# 我使用的是MsggPack CLI,您可以在

根据msgpack.org文档,序列化模型

{"model":"message"}
六边形

81 a5 6d 6f 64 65 6c a7 6d 65 73 73 61 67 65
但是当试图在c#中做同样的事情时(当然是用一种幼稚的方法)

我得到

91 a7 6d 65 73 73 61 67 65
其中跳过了“模型”名称


如何修复它?

终于找到了简单的方法。 根据文档,序列化格式默认为“array”,其中我需要“map”。 使用

耍花招

问候

91 a7 6d 65 73 73 61 67 65
SerializationContext ctx = new SerializationContext() { SerializationMethod = SerializationMethod.Map };
...

var requestSerializer = MessagePackSerializer.Get(a.GetType(), ctx);