Filtering JSON to retrieve specific key/values
Options
![Patrick Steil](https://us.v-cdn.net/6037124/user_avatars/3747199.jpg)
Patrick Steil
Member ✭
I am calling an API which retrieves a list of servers and the apps within those servers. Here is the pertinent json:
```
[
{
"id": "257115",
"label": "SERVER1",
"apps": [
{
"id": "800662",
"label": "www.site1.com"
},
{
"id": "812522",
"label": "www.site2.com"
}
]
},
{
"id": "268339",
"label": "SERVER2",
"apps": [
{
"id": "832438",
"label": "www.site3.com"
},
{
"id": "832441",
"label": "www.site4.com"
}
]
}
]
```
What I want to do is - based on in input variable, return all the "apps" for one server id at a time, say "257115" - so it would only return:
```
"apps": [
{
"id": "800662",
"label": "www.site1.com"
},
{
"id": "812522",
"label": "www.site2.com"
}
]
```
Any docs or videos showing how to do this?
Thanks!
```
[
{
"id": "257115",
"label": "SERVER1",
"apps": [
{
"id": "800662",
"label": "www.site1.com"
},
{
"id": "812522",
"label": "www.site2.com"
}
]
},
{
"id": "268339",
"label": "SERVER2",
"apps": [
{
"id": "832438",
"label": "www.site3.com"
},
{
"id": "832441",
"label": "www.site4.com"
}
]
}
]
```
What I want to do is - based on in input variable, return all the "apps" for one server id at a time, say "257115" - so it would only return:
```
"apps": [
{
"id": "800662",
"label": "www.site1.com"
},
{
"id": "812522",
"label": "www.site2.com"
}
]
```
Any docs or videos showing how to do this?
Thanks!
Comments
-
I'd probably use Array: Find First Element - or Array: Find All Matched Elements (if there's more than of that ID)
https://docs.xano.com/working-with-data/functions/data-manipulation/arrays -
Thanks for the answer! I'll try it out!
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