Extracting values from Json (Reverse Geocoding Google Map API )

Hi,
I need assistance in extracting the values display under property “long_name” under “address_components” list; so I can get the enterie address base on a latitude and logitude values; I’m using the location sensor component and a web api from google maps
Thanks,

the json that comes out of the google geocoding api is:

{
“plus_code” : {
“compound_code” : “RHR3+98 Santa Lucia, El Salvador”,
“global_code” : “765GRHR3+98”
},
“results” : [
{
“address_components” : [
{
“long_name” : “Calle Francisco Gavidia”,
“short_name” : “Calle Francisco Gavidia”,
“types” : [ “route” ]
},
{
“long_name” : “Ciudad Arce”,
“short_name” : “Cd Arce”,
“types” : [ “locality”, “political” ]
},
{
“long_name” : “Ciudad Arce”,
“short_name” : “Cd Arce”,
“types” : [ “administrative_area_level_2”, “political” ]
},
{
“long_name” : “La Libertad”,
“short_name” : “La Libertad”,
“types” : [ “administrative_area_level_1”, “political” ]
},
{
“long_name” : “El Salvador”,
“short_name” : “SV”,
“types” : [ “country”, “political” ]
}
],
“formatted_address” : “Calle Francisco Gavidia, Cd Arce, El Salvador”,
“geometry” : {
“bounds” : {
“northeast” : {
“lat” : 13.841047,
“lng” : -89.44653409999999
},
“southwest” : {
“lat” : 13.8408049,
“lng” : -89.44662219999999
}
},
“location” : {
“lat” : 13.8409264,
“lng” : -89.44657699999999
},
“location_type” : “GEOMETRIC_CENTER”,
“viewport” : {
“northeast” : {
“lat” : 13.8422749302915,
“lng” : -89.44522916970848
},
“southwest” : {
“lat” : 13.8395769697085,
“lng” : -89.44792713029149
}
}
},
“place_id” : “ChIJC5bVJcPeYo8R6st1j-xy_Ms”,
“types” : [ “route” ]
},
{
“address_components” : [
{
“long_name” : “Ciudad Arce Centro”,
“short_name” : “Cd Arce Centro”,
“types” : [ “neighborhood”, “political” ]
},
{
“long_name” : “Santa Lucia”,
“short_name” : “Santa Lucia”,
“types” : [ “locality”, “political” ]
},
{
“long_name” : “Ciudad Arce”,
“short_name” : “Cd Arce”,
“types” : [ “administrative_area_level_2”, “political” ]
},
{
“long_name” : “La Libertad”,
“short_name” : “La Libertad”,
“types” : [ “administrative_area_level_1”, “political” ]
},
{
“long_name” : “El Salvador”,
“short_name” : “SV”,
“types” : [ “country”, “political” ]
}
],
“formatted_address” : “Cd Arce Centro, Santa Lucia, El Salvador”,
“geometry” : {
“bounds” : {
“northeast” : {
“lat” : 13.8445803,
“lng” : -89.44004059999999
},
“southwest” : {
“lat” : 13.8367674,
“lng” : -89.4481945
}
},
“location” : {
“lat” : 13.8391144,
“lng” : -89.4440774
},
“location_type” : “APPROXIMATE”,
“viewport” : {
“northeast” : {
“lat” : 13.8445803,
“lng” : -89.44004059999999
},
“southwest” : {
“lat” : 13.8367674,
“lng” : -89.4481945
}
}
},
“place_id” : “ChIJ9fji6NzeYo8R3iLj-UUGxg4”,
“types” : [ “neighborhood”, “political” ]
},
{
“address_components” : [
{
“long_name” : “Santa Lucia”,
“short_name” : “Santa Lucia”,
“types” : [ “locality”, “political” ]
},
{
“long_name” : “Ciudad Arce”,
“short_name” : “Cd Arce”,
“types” : [ “administrative_area_level_2”, “political” ]
},
{
“long_name” : “La Libertad”,
“short_name” : “La Libertad”,
“types” : [ “administrative_area_level_1”, “political” ]
},
{
“long_name” : “El Salvador”,
“short_name” : “SV”,
“types” : [ “country”, “political” ]
}
],
“formatted_address” : “Santa Lucia, El Salvador”,
“geometry” : {
“bounds” : {
“northeast” : {
“lat” : 13.8498722,
“lng” : -89.41884039999999
},
“southwest” : {
“lat” : 13.8189031,
“lng” : -89.45274350000001
}
},
“location” : {
“lat” : 13.8354794,
“lng” : -89.4387562
},
“location_type” : “APPROXIMATE”,
“viewport” : {
“northeast” : {
“lat” : 13.8498722,
“lng” : -89.41884039999999
},
“southwest” : {
“lat” : 13.8189031,
“lng” : -89.45274350000001
}
}
},
“place_id” : “ChIJb6L_kSffYo8RB4JT3_9nCKs”,
“types” : [ “locality”, “political” ]
},
{
“address_components” : [
{
“long_name” : “Ciudad Arce”,
“short_name” : “Ciudad Arce”,
“types” : [ “administrative_area_level_2”, “political” ]
},
{
“long_name” : “La Libertad Department”,
“short_name” : “La Libertad Department”,
“types” : [ “administrative_area_level_1”, “political” ]
},
{
“long_name” : “El Salvador”,
“short_name” : “SV”,
“types” : [ “country”, “political” ]
}
],
“formatted_address” : “Ciudad Arce, El Salvador”,
“geometry” : {
“bounds” : {
“northeast” : {
“lat” : 13.8794127,
“lng” : -89.3895721
},
“southwest” : {
“lat” : 13.7587273,
“lng” : -89.47196959999999
}
},
“location” : {
“lat” : 13.7977568,
“lng” : -89.41746409999999
},
“location_type” : “APPROXIMATE”,
“viewport” : {
“northeast” : {
“lat” : 13.8794127,
“lng” : -89.3895721
},
“southwest” : {
“lat” : 13.7587273,
“lng” : -89.47196959999999
}
}
},
“place_id” : “ChIJSfdXXNDYYo8R767pb8QwJd8”,
“types” : [ “administrative_area_level_2”, “political” ]
},
{
“address_components” : [
{
“long_name” : “La Libertad Department”,
“short_name” : “La Libertad Department”,
“types” : [ “administrative_area_level_1”, “political” ]
},
{
“long_name” : “El Salvador”,
“short_name” : “SV”,
“types” : [ “country”, “political” ]
}
],
“formatted_address” : “La Libertad Department, El Salvador”,
“geometry” : {
“bounds” : {
“northeast” : {
“lat” : 14.0608631,
“lng” : -89.133437
},
“southwest” : {
“lat” : 13.4222451,
“lng” : -89.6249409
}
},
“location” : {
“lat” : 13.6817661,
“lng” : -89.3606298
},
“location_type” : “APPROXIMATE”,
“viewport” : {
“northeast” : {
“lat” : 14.0608631,
“lng” : -89.133437
},
“southwest” : {
“lat” : 13.4222451,
“lng” : -89.6249409
}
}
},
“place_id” : “ChIJj7ku93kjY48RJGGpDtNMEcI”,
“types” : [ “administrative_area_level_1”, “political” ]
},
{
“address_components” : [
{
“long_name” : “El Salvador”,
“short_name” : “SV”,
“types” : [ “country”, “political” ]
}
],
“formatted_address” : “El Salvador”,
“geometry” : {
“bounds” : {
“northeast” : {
“lat” : 14.4505567,
“lng” : -87.6682
},
“southwest” : {
“lat” : 13.0473999,
“lng” : -90.19229999999999
}
},
“location” : {
“lat” : 13.794185,
“lng” : -88.89653
},
“location_type” : “APPROXIMATE”,
“viewport” : {
“northeast” : {
“lat” : 14.4505567,
“lng” : -87.6682
},
“southwest” : {
“lat” : 13.0473999,
“lng” : -90.19229999999999
}
}
},
“place_id” : “ChIJVwZkWaYnY48RMkiFmOsWmm8”,
“types” : [ “country”, “political” ]
}
],
“status” : “OK”
}

Hey @boris.hernandez thanks for sharing :+1:

The object blocks are able to do exactly what you need.

Also, we have a great playlist with API resources you can watch here:

Hope that helps!

1 Like

Thanks for your quick response
I’ll review the videos sent
kind regards,

Hi Boris. Did you work out a solution to this problem? I am facing the same issues and could also use some help.

Before using the object blocks, I would normally use “Json editor” to view exactly where the info I wanted to extract resides, especially with nested levels. Cut and paste the whole JSON and it will present the data in readable objects levels. Then you can use the object blocks with the correct properties to access the data. Note that some of the data are contained in square brackets, those are in a “list” so you need to use list blocks to read them.

https://jsoneditoronline.org/#left=local.lezuxu&right=local.fovoki

2 Likes

I do the same @gobassky.

https://jsonpathfinder.com/

3 Likes