Querying and transforming object (using Google Places API)
Hi, I am using the Google Places API and would like to extract some information and write it to a table.
I would like to save the address in a table of "service providers". The concept of what is a city differs hugely when looking at a global level. So I would like to store the administrative_area_levels, als Google calls them.
I thought of storing them as an object.
The response contains this:
[
{
"long_name": "Jalan Munduk Tengah",
"short_name": "Jl. Munduk Tengah",
"types": ["route"]
},
{
"long_name": "Kabupaten Badung",
"short_name": "Kabupaten Badung",
"types": ["administrative_area_level_2", "political"]
},
{
"long_name": "Bali",
"short_name": "Bali",
"types": ["administrative_area_level_1", "political"]
},
{
"long_name": "80351",
"short_name": "80351",
"types": ["postal_code"]
}]
I would like to transform and save it like this:
{
"administrative_area_level_1": "Bali",
"administrative_area_level_2": "Kabupaten Badung",
"administrative_area_level_3": "Kecamatan Mengwi"
}
Unfortunately I tried many filters and functions but couldn't get it done-
Comments
-
Hello Marfi,
If you recreate the function stack below, you should be good to go. -
Thank you very much. That worked well.
Now I tried to only merge the
item_transformed
to thetransformed_array
, when it contains "administrative_area_level", but cannot get it to work.I used set_conditional like seen on the screenshot below, but the variable remains empty then. Any idea?
-
Hello Marfi,
I fixed your function stack by adding one function before the loop called Array: Find All Elements, setting it up as shown in the image, and I called it only_with_administrative. After that replace the Google_places array with this on only_with_administrative.The whole process as well as the test to show it works can be seen below.
-
Thank you so much, I made it work with that function.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback