public static RootObject ReadToObject(string json) { RootObject deserializedUser = new RootObject(); MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json)); DataContractJsonSerializer ser = new DataContractJsonSerializer(deserializedUser.GetType()); deserializedUser = ser.ReadObject(ms) as RootObject; ms.Close(); return deserializedUser; }
//Updating the Past 10 weather report list public void updateArchiveList(RootObject r) { List<SampleResult> sl = new List<SampleResult>(); foreach (var item in r.results) { sl.Add(new SampleResult() { sol = item.sol, max_temp_fahrenheit=item.max_temp_fahrenheit.ToString("#")+"°F",min_temp_fahrenheit =item.min_temp_fahrenheit.ToString("#") + "°F", ImagePath = path(item) }); } this.list.ItemsSource =sl; }