public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jo = JObject.Load(reader); AirIndex index = jo.ToObject <AirIndex>(); index.Value = jo.SelectToken("stIndexLevel.indexLevelName").ToString(); return(index); }
public async Task <AirIndex> GetAirQualityIndex(int stationId) { AirIndex index = new AirIndex(); using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://api.gios.gov.pl/pjp-api/rest/"); string req = String.Format("aqindex/getIndex/{0}", stationId); var response = await client.GetAsync(req); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); index = JsonConvert.DeserializeObject <AirIndex>(result, new IndexConverter()); } } return(index); }