„Get out from smog” – parsing JSON

dsp2017

„Get out from smog” part II

Today I will focus on parsing data from JSON.

Service http://powietrze.gios.gov.pl provides information on air quality in this format. So I would use this information in my application. In the first step I need to download it.

Use to this – webClient class to dowload string from website and additionally, need to set encoding to UTF8 to have the Polish special characters.

Next, I parses JSON to the materialized object like list, which got two properites:

To parse JSON i use Newtonsoft Json.

After parsing as you see I have 162 count places where air quality is measured.

json parse

Also if you like dynamic you can write your parse code like this:

Both code return exacly the same data. Code based on dynamic looks more clear but without strong typing.

In next episode I’ll try to get longitudes of measuring stations.

Link to the project : here

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *