JsonConvert.DeserializeObject and “d” wrapper in WCF

后端 未结 7 467
梦谈多话
梦谈多话 2020-12-21 08:53

By default WCF service wrap JSON response in \"d\" wrapper and there I found a problem with parsing it.

If I parse with JsonConvert.DeserializeObject(respons

相关标签:
7条回答
  • 2020-12-21 09:21

    Take your json and paste it into an online class generator, like http://httputility.net/json-to-csharp-vb-typescript-class.aspx. It will provide you the code to deserialize this json object into, like this (VB example):

    Public Class MyClass
         Public Property D As String
    End Class
    

    Paste this into your project and deserialize the json into this object. The D property now is a string that contains the unwrapped json you'll need to deserialize a second time into your final receiving object. If you are unsure of the class you'll need to handle it, paste the string in D into the same online class generator and you'll have the code necessary to create the type to receive the object!

    0 讨论(0)
提交回复
热议问题