How can I deserialize JSON containing delimited JSON?

后端 未结 1 1491
误落风尘
误落风尘 2020-12-19 05:50

I have a problem with deserializing a Json-string to an object.

This is a sample json i receive from a webservice:

{
    \"GetDataResult\":
                  


        
相关标签:
1条回答
  • 2020-12-19 06:26

    The json response contains an object that within itself contains a json string representing the data result.

    You need to deserialize twice, once for the response and one more for the data result.

    var response = JsonConvert.DeserializeObject<JObject>(responseStr);
    var dataResult = (string)response["GetDataResult"];
    var cityData = JsonConvert.DeserializeObject<CityData>(dataResult);
    
    0 讨论(0)
提交回复
热议问题