Hello,
I am using an HTTP module to return a set of data that looks like:
{
“results”: [
{
“address_components”: [
{
“long_name”: “90001”,
“short_name”: “90001”,
“types”: [
“postal_code”
]
},
{
“long_name”: “Los Angeles”,
“short_name”: “Los Angeles”,
“types”: [
“locality”,
“political”
]
},
{
“long_name”: “Los Angeles County”,
“short_name”: “Los Angeles County”,
“types”: [
“administrative_area_level_2”,
“political”
]
},
{
“long_name”: “California”,
“short_name”: “CA”,
“types”: [
“administrative_area_level_1”,
“political”
]
},
{
“long_name”: “United States”,
“short_name”: “US”,
“types”: [
“country”,
“political”
]
}
],
“postcode_localities”: [
“Florence-Graham”,
“Huntington Park”,
“Los Angeles”
],
“types”: [
“postal_code”
]
}
],
“status”: “OK”
}
How can I then filter the array ‘address_components’ to return a specified value based on a condition of the nested arrays ‘types’. For instance, given the data above return the ‘long_name’ value where there is a value ‘locality’ in the nested array ‘types’ of said object. The result should be ‘Los Angeles’.