Deserializing JSON and access to elements

后端 未结 2 1788
心在旅途
心在旅途 2021-01-29 14:55

I have the following code :

dynamic stuff = JsonConvert.DeserializeObject(\"{ \'Name\': \'Jon Smith\', \'Address\': [\'A\', \'B\', \'C\'], \'Age\': 42 }\");
var          


        
2条回答
  •  Happy的楠姐
    2021-01-29 15:22

    You can use the same approach with Name property, then iterate the Address value, since it's an array

    var address = stuff.Address;
    foreach (var item in address)
    {
        Console.WriteLine(item);
    }
    

提交回复
热议问题