2
我们有DTO类是这样的:展开词典JSON领域
public class DTO
{
public int Number { get; set; }
public string Title { get; set; }
public Dictionary<string, string> CustomFields { get; set; }
}
我想序列/由ServiceStack以JSON其中CustomFields被扩展为DTO领域反序列化的DTO。例如
new DTO
{
Number = 42
Title = "SuperPuper"
CustomFields = new Dictionary<string, string> {{"Description", "HelloWorld"}, {"Color", "Red"}}
}
连载到
{
"Number":42,
"Title":"SuperPuper",
"Description":"HelloWorld",
"Color":"Red"
}
我怎样才能做到这一点?
- 在序列化过程中,所有字典字段必须表示为JSON对象字段。
- 在反序列化期间,不是DTO字段的传入JSON对象的所有字段都必须置于Dictionary中。
那么反序列化呢?将说明直接进入字典? – adt 2013-03-27 13:59:09
不可以。您问过物体是否变平,现在变平了。 – 2013-03-27 15:10:23
@SteveWellens:问题状态_I要序列化/反序列化_ – starteleport 2013-03-27 16:00:12