Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }