Generate lightweight JSON using DataContractJsonSerializer

后端 未结 2 929
没有蜡笔的小新
没有蜡笔的小新 2021-01-14 19:50

I\'m trying to generate JSON using C# and DataContractJsonSerializer in .Net 3.5. The problem is that I can\'t figure out how to build the structure correct for the result I

2条回答
  •  执笔经年
    2021-01-14 20:38

    Using the JavaScriptSerializer rather than DataContractJsonSerializer on a Dictionary will remove the Key/Value json attributes and make them into a "keyed" array.

    http://msdn.microsoft.com/en-us/library/bb412168.aspx

    Have you attributed your classes with the [DataContract] and [DataMember] decorators?

    http://msdn.microsoft.com/en-us/library/bb412179.aspx

提交回复
热议问题