c# - Read Json inner node -


i have json string in "responsetext"

then deserialized string using

var getjson = jsonconvert.deserializeobject(responsetext); 

i josn my json output

now want country name 0 > address_components.

i want read node child node contain types country

you can see

results > 0 > address_components > 8 > types > 0 

the result of deserializeobject object. best if dynamic object. can retrieve sub items array or dictionary (depening json sub item is).

        dynamic receiveddata = jsonconvert.deserializeobject<dynamic>(json);          var addresses = receiveddata["results"][0]["address_components"];         var firstadress = addresses[0]; 

also remember name variables , functions correctly. getjson not name because not retrieve json. rename retrieveddata or something.

edit: use of dynamic, original example didn't work.


Comments