【发布时间】:2010-05-16 16:17:00
【问题描述】:
我有一个包含项目列表的类。 我想使用 DataContractJsonSerializer 作为 json 数组将此类的实例序列化为 json。例如。
class MyClass
{
List<MyItem> _items;
}
class MyItem
{
public string Name {get;set;}
public string Description {get;set;}
}
序列化为json应该是这样的:
[{"Name":"one","Description":"desc1"},{"Name":"two","Description":"desc2"}]
【问题讨论】:
-
你有什么问题?您对此有疑问吗?
-
FWIW 你应该检查一下 Json.NET 序列化程序,因为它比 WCF Json 序列化程序性能要好得多。
标签: c# json datacontractserializer datacontractjsonserializer