Parse a table to javascript

This is the first part in a series where I will query and parse the SMHI (Sveriges meteorologiska och hydrologiska institut) API for weather data. This will be a short post where I just work in the Chrome dev tools. I also created a repo to put snippets and code that I use in this series.

When we query the API we get a list of parameters that will look something like this:

The actual data for weather symbol we get from the API

And the value in the values array will correspond to a symbol/meaning. We can find the meaning of this in a table. But we need it in our code. We could just write it by hand and it would be done quickly, but what is the fun in that? This is how the table and its markup looks:

The table
The markup

Looks easy enough, but there are more tables on the page so we will have to make sure we get the correct table when querying. The table happens to be the last in the list so this should be easy.

The code, written in Chromes snippets that will get and parse the table to a map object

Now we have a neat object that we can use to know what symbol we should use when we parse the API.

Output from the script above

Hope this at least was somewhat interesting. This series is most likely what I will continue to write next.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.