Filtering: Array and Object Queries

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’.

The map() function. Learn it. Love it. Live it.

1 Like

Learn from here:

For detailed class: https://www.msquare.pro/masterclass-handle-array-collection

3 Likes

Thanks for this resource. I think my issue stems from the nested aray within the array of objects. I realize that map can filter by expected value, but it’s expecting a string or text data type to filter, not an array, which is what what is throwing me off. Am i missing that?

Work through this document. Map() takes an array or collection as an input.

This may be the most important technique you’ll learn in make so take it slow and actually try some examples first.

If you need real time help we offer a one hour video call where we explain and show how Make can help your organization. We even build some scenarios and share them with you so get more value than a usual exploratory discussion. Book some time with me at Make.com Hero - NewPath Consulting I look forward to talking to you and your team should they join us.

1 Like

@tazmann Did you find a solution to this? I am trying to do the same thing and am having no luck.