【发布时间】:2020-08-18 09:27:29
【问题描述】:
我目前正在开发一个 web 服务,并且我有这种行为,直到今天我还没有遇到过。这是我要返回的课程:
public class Block
{
public int order { get; set; }
public string title { get; set; }
public Dictionary<string, object> attributes { get; set; }
}
attributes 可以包含任何类型的值:简单类型、对象、数组等。
当我通过我的网络服务返回一个Block 对象时,我得到了:
{
"order": 1,
"attributes": [
{
"Key": "key1",
"Value": "value1"
},
{
"Key": "key2",
"Value": "value2"
}
],
"title": "Title"
}
有谁知道我为什么不简单地得到 "key1": "value1" 输出?
【问题讨论】:
-
也许您可以向我们展示您用于序列化对象的代码!
标签: c# json dictionary