Question

Filtering an array field inside of the input data

  • 15 January 2024
  • 3 replies
  • 53 views

Hi

I have a Zap that produces output that looks like:
 

{
"id":123,
"name":"Joe",
"items": [
{
"id":"ABC",
"type":"type1"
},
{
"id":"XYZ",
"type":"type2"
},
{
"id":"BEY",
"type":"type1"
}
]
}

 

I want to specifically filter the items array to only include items of a specific type. I want the output to include all other fields, in this case the output for filtering on `type1` should be:

 

{
"id":123,
"name":"Joe",
"items": [
{
"id":"ABC",
"type":"type1"
},
{
"id":"BEY",
"type":"type1"
}
]
}

 

Is there an easy way to accomplish this?


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Userlevel 7
Badge +14

Hi @gzcal 

Good question.

Help articles:

 

Thanks @Troy Tessalone 

I don't think either of those work in this case - my main problem is I want to keep all the other fields from the input. I just want to filter out object with a specific type in the items subfield

Userlevel 7
Badge +14

@gzcal 

Try asking ChatGPT for help with the JavaScript/Python Code to filter the JSON.