[Solved] Getting objects from JSON

I am having trouble getting values from this JSON.

Can anyone help me, with how to get the vallue of maxspeed (First occurrence)

{ "version": 0.6, "generator": "Overpass API 0.7.55.7 8b86ff77", "osm3s": { "timestamp_osm_base": "2019-09-27T21:32:02Z", "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL." }, "elements": [ { "type": "way", "id": 110361079, "nodes": [ 1357949914, 147458, 25508750, 147456, 1357949890, 147454, 1357949889, 118893, 428910226, 1357949911, 118894, 1357949909, 3625850452 ], "tags": { "hazard": "animal_crossing", "highway": "motorway", "int_ref": "E 20", "lanes": "3", "lit": "no", "maxspeed": "110", "maxspeed:variable": "yes", "name": "Øresundsmotorvejen", "oneway": "yes", "ref": "E 20", "source:maxspeed": "sign", "surface": "asphalt" } }, { "type": "way", "id": 316057646, "nodes": [ 411808320, 408435172, 1344122132, 408433893, 408433892, 1357949913, 428910226 ], "tags": { "destination": "Malmö", "destination:ref": "E20", "highway": "motorway_link", "oneway": "yes", "surface": "asphalt" } }, { "type": "way", "id": 357265310, "nodes": [ 3625850454, 1357949898, 147451, 428910363, 147452, 1344122133, 147453, 1357949895, 1357949902, 1357949905, 147457, 1357949908, 147461 ], "tags": { "highway": "motorway", "int_ref": "E 20", "lanes": "3", "lit": "no", "maxspeed": "110", "name": "Øresundsmotorvejen", "oneway": "yes", "ref": "E 20", "source:maxspeed": "sign", "surface": "asphalt" } }, { "type": "way", "id": 376150397, "nodes": [ 147452, 3795893622, 3795893623, 3795893624, 3795893625, 3795893626, 3795893627 ], "tags": { "destination": "Ørestad;Bella Center", "destination:symbol": "train_station", "highway": "motorway_link", "lanes": "1", "oneway": "yes" } } ] }
2 Likes

Hi @Claus_Holbech1,

Have you tried using the Object blocks to access the individual values in this array?

3 Likes

Hi there,

It is easier to understand how to get the value you are looking for when your JSON is formatted properly.
There are websites that will do this automatically for you.
This is the first one I found when I looked for such a service online.

We can see that ‘maxspeed’ is inside an object called ‘tags’, and that ‘tags’ is the third element of the list ‘elements’ inside this response.

These blocks will get the value of “maxspeed”:

You can see the app I created with these blocks here.

4 Likes

Thank you very much, that works fine.

Claus

2 Likes