“Get out from smog” – parsing JSON

“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

Leave a Reply

Your email address will not be published. Required fields are marked *