如何仅将字典的值序列化为json(使用json.net)

问题描述:

使用Json.NET将字典作为其值列表序列化为json的最简单方法是什么?

what is easiest way to serialize dictionary as list of its values into json using Json.NET?

序列化是由SignalR完成的,而不是我.因此,我需要某种类似于属性的方式或自定义合同解析器或类似的东西.

Serialization is done by SignalR, not me. So I need some attribute-like way or custom contract resolver or something like that.

对于服务器端而言,字典对我来说更好,但对于客户端上的绑定到数据网格而言,扁平化对象会更好.

Dictionary is better for me on the server side but for the binding into data grid on the client, flatten object would be better.

谢谢

您是否正在寻找类似的东西;

Are you looking for something like that;

JsonConvert.SerializeObject(dictionary.Values.ToList());