Deserialization problem with DataContractJsonSerializer

前端 未结 2 1776
失恋的感觉
失恋的感觉 2020-12-01 12:34

I\'ve got the following piece of JSON:

[{
    \"name\": \"numToRetrieve\",
    \"value\": \"3\",
    \"label\": \"Number of items to retrieve:\",
    \"items         


        
2条回答
  •  不思量自难忘°
    2020-12-01 12:49

    IMHO there is no way to deserialize the JSON string you provided into a .NET class using DataContractJsonSerializer.

    The problem comes from the way DataContractJsonSerializer serializes dictionaries. You could use an alternative serializer such as Json.NET (which I strongly recommend) or JavaScriptSerializer (I think it was deprecated in favor of DataContractJsonSerializer but it will work for your scenario).

    You can also read these rants.

    Documentation: Serializing Collections - Json.NET

提交回复
热议问题