Hi folks. I am hoping someone can put me out of my misery. Having searched the forums for advice and found a few relevant posts, I still am unable to process the response from Google API for a reverse Geocode lookup. The app just crashes with no explanation and I cannot work out what I am doing wrong. Any help greatly appreciated.
For brevity’s sake I have included the top section of the response from the Google API call as follows:
{
“plus_code” : {
“compound_code” : “CPFF+5G Saltash, UK”,
“global_code” : “9C2QCPFF+5G”
},
“results” : [
{
“address_components” : [
{
“long_name” : “Junction”,
“short_name” : “Junction”,
“types” : [ “establishment”, “point_of_interest”, “transit_station” ]
},
{
"long_name" : “Notter”,
“short_name” : “Notter”,
“types” : [ “locality”, “political” ]
},
{
“long_name” : “Saltash”,
“short_name” : “Saltash”,
“types” : [ “postal_town” ]
},
{
“long_name” : “Cornwall”,
“short_name” : “Cornwall”,
“types” : [ “administrative_area_level_2”, “political” ]
},
{
“long_name” : “England”,
“short_name” : “England”,
“types” : [ “administrative_area_level_1”, “political” ]
},
{
“long_name” : “United Kingdom”,
“short_name” : “GB”,
“types” : [ “country”, “political” ]
},
{
“long_name” : “PL12 4RP”,
“short_name” : “PL12 4RP”,
“types” : [ “postal_code” ]
}
],
“formatted_address” : “Junction, Notter, Saltash PL12 4RP, UK”,
“geometry” : {
“location” : {
“lat” : 50.424553,
“lng” : -4.275668
},
“location_type” : “GEOMETRIC_CENTER”,
“viewport” : {
“northeast” : {
“lat” : 50.42590198029149,
“lng” : -4.274319019708497
},
“southwest” : {
“lat” : 50.42320401970849,
“lng” : -4.277016980291502
}
}
},
“place_id” : “ChIJCb0VssSRbEgRoguGSPf3iAI”,
“plus_code” : {
“compound_code” : “CPFF+RP Saltash, UK”,
“global_code” : “9C2QCPFF+RP”
},
“types” : [ “establishment”, “point_of_interest”, “transit_station” ]
},
{
“address_components” : [
{
My target field is in bold above.
I think the path is as follows:
long_name - 2 - address_components - 1 - results
So I convert the json response to an object and using “get property of object” and “in list get” I attempt to get to my text field populated with the target field from the response from Google API.
This is my block:
I’ve attempted various other approaches as per examples in the forums but they all result in the same outcome.
Can anyone spot what my error is and walk me on to it?
Thanks.
Roger