Deserializing complex object using Json.NET

前端 未结 3 1400
甜味超标
甜味超标 2021-01-02 04:19

I need to deserialize the this json returned from grogle maps api:

{
    \"destination_addresses\": [
        \"Via Medaglie D\'Oro, 10, 47121 Forlì FC, Ital         


        
3条回答
  •  没有蜡笔的小新
    2021-01-02 04:36

    I believe the issue is with the cast to 'DataSet' based on a similar question I found searching Stack Overflow.

    Try this as I believe it would work (you may need to use 'rows' instead of 'Elements', but I believe the approach of using a JObject will resolve the primary issue of the 'additional text'.

     JObject json = JsonConvert.DeserializeObject(jsonResponse);
     foreach (Dictionary item in data["Elements"])
     {
        foreach (string val in item.Values) {
            Console.WriteLine(val);
        }
      }
    

提交回复
热议问题