How to use this json variable in C#? -
i want data in json , use them in program. use these codes:
public class test { public class coord { public double lon { get; set; } public double lat { get; set; } } public class weather { public int id { get; set; } public string main { get; set; } public string description { get; set; } public string icon { get; set; } } public class root { public coord coord { get; set; } public list<weather> weather { get; set; } public string name { get; set; } } }
i know how use simple variables this:
var obj = jsonconvert.deserializeobject<test.root>(jsontest); double mylon = obj.coord.lon;
my question how use variables inside weather class because defined in list! example want store "icon" in string variable. im new in c#, me please.
since weather of type list'1
, have access list using index:
double icon = obj.weather[0].icon
or using linq:
double icon = obj.weather.first().icon
you can have multiple weather
objects in list, treat accordingly.
Comments
Post a Comment