我需要将一组对象序列化为 JSON 字典。
像这样的数组项:
class Entry {
public string Id{get;set;}
public string Value{get;set;}
}
所以像数组一样
var arr = new[]
{
new Entry{Id = "one", Value = "First"},
new Entry{Id = "two", Value = "Second"},
new Entry{Id = "tri", Value = "Third"},
};
我希望被序列化如下:
{
one: {Title: "First"},
two: {Title: "Second"},
tri: {Title: "Third"}
}
可能吗?ContractResolver附近的东西?
谢谢。