Send feedback
Stay organized with collections
Save and categorize content based on your preferences.
See the supported connectors for Application Integration.
FILTER function
FILTER
function
Function Name
Description
Usage
Input parameter
Return value
FILTER
Filters the array elements that satisfy a given filter condition.
Note that a filter condition must evaluate to TRUE or FALSE.
A filter condition includes one or more transformation functions applied on the current array iteration element.
FILTER(~objn -> Variable or Value)
Where ~objn indicates the current array element for which you want to apply the transformation functions. By default, the value for n starts from 1.
For JSON arrays with schema, you can use a dot (.) notation following the current array element to directly access the nested property of the that array element. For example, ~objn . PROPERTY
.
A filter condition that evaluates to TRUE or FALSE.
An array of elements that match the filter condition.
Supported data type
The FILTER
function supports the following data types:
Boolean array
Double array
Integer array
JSON
String array
Example 1: Filter a string array.
Sample data :
$var1$ = {
"sara@example.com",
"bola@example.com",
"222larabrown@gmail.com",
"dana@examplepetstore.com",
"cloudysanfrancisco@gmail.com"}
Usage : $var1$.FILTER(~obj1-> ~obj1.CONTAINS("@gmail.com"))
Filter the string elements which contain @gmail.com in var1 .
Output :
{"222larabrown@gmail.com","cloudysanfrancisco@gmail.com"}
Example 2: Filter a JSON array.
Sample data :
$var1$ = {
"citynames": [
{
"city": "Abbeville",
"state": "Louisiana"
},
{
"city": "Aberdeen",
"state": "Maryland"
},
{
"city": "Benicia",
"state": "California"
},
{
"city": "Chehalis",
"state": "Washington"
},
{
"city": "Aberdeen",
"state": "Washington"
},
{
"city": "Aberdeen",
"state": "Mississippi"
},
{
"city": "Cheektowaga",
"state": "New York"
}
]
}
Usage :
var1 .citynames
.FILTER(~obj1->
~obj1
.GET_PROPERTY("city")
.EQUALS("Aberdeen")
)
Filter the elements which have the city as Aberdeen in var1 .
Output :
[{
"city": "Aberdeen",
"state": "Maryland"
},
{
"city": "Aberdeen",
"state": "Washington"
},
{
"city": "Aberdeen",
"state": "Mississippi"
}]
Example 3: Filter a nested JSON array.
Sample data :
$var1$ =
{
"products": [
{
"PA": "Integrations",
"users": [
{
"name": "Ariel",
"role": [
"editor",
"approver"
]
},
{
"name": "Dana",
"role": [
"admin",
"deployer"
]
},
{
"name": "Lee",
"role": [
"viewer"
]
}
]
},
{
"PA": "Apigee",
"users": [
{
"name": "Mahan",
"role": [
"editor",
"admin",
"deployer"
]
},
{
"name": "Quinn",
"role": [
"invoker"
]
}
]
},
{
"PA": "Connectors",
"users": [
{
"name": "Kiran",
"role": [
"invoker",
"admin",
"deployer"
]
},
{
"name": "Sasha",
"role": [
"admin"
]
}
]
}
]
}
Usage :
var1 .products
.FOR_EACH(~obj1 ->
~obj1
.SET_PROPERTY(
~obj1
.GET_PROPERTY("users")
.FILTER(~obj2 ->
~obj2
.GET_PROPERTY("role")
.TO_STRING()
.CONTAINS("admin")
)
,
"users"
)
)
Filter the elements which contain admin in users of var1 .
Output :
[{
"PA": "Integrations",
"users": [{
"name": "Dana",
"role": ["admin", "deployer"]
}]
}, {
"PA": "Apigee",
"users": [{
"name": "Mahan",
"role": ["editor", "admin", "deployer"]
}]
}, {
"PA": "Connectors",
"users": [{
"name": "Kiran",
"role": ["invoker", "admin", "deployer"]
}, {
"name": "Sasha",
"role": ["admin"]
}]
}]
Recommendation
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-26 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-26 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eFILTER\u003c/code\u003e function in Application Integration allows filtering array elements based on a specified condition that evaluates to TRUE or FALSE.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFILTER\u003c/code\u003e function supports various data types, including Boolean, Double, Integer, JSON, and String arrays.\u003c/p\u003e\n"],["\u003cp\u003eThe current array element is referred to as \u003ccode\u003e~obj<var translate="no">n</var>\u003c/code\u003e within the \u003ccode\u003eFILTER\u003c/code\u003e function's condition, starting with \u003ccode\u003e~obj1\u003c/code\u003e by default.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFILTER\u003c/code\u003e function can be applied to nested arrays within JSON structures, as shown in Example 3.\u003c/p\u003e\n"],["\u003cp\u003eThree examples are provided demonstrating how to use \u003ccode\u003eFILTER\u003c/code\u003e: filtering a string array, filtering a JSON array, and filtering a nested JSON array, with detailed sample data, usage, and output for each.\u003c/p\u003e\n"]]],[],null,["# FILTER function\n\nSee the [supported connectors](/integration-connectors/docs/connector-reference-overview) for Application Integration.\n\nFILTER function\n===============\n\n`FILTER` function\n-----------------\n\nSupported data type\n-------------------\n\n\nThe `FILTER` function supports the following data types:\n\n- Boolean array\n- Double array\n- Integer array\n- JSON\n- String array\n\nExample 1: Filter a string array.\n---------------------------------\n\n\n**Sample data** :\n`\n$var1$ = {\n\"sara@example.com\",\n\"bola@example.com\",\n\"222larabrown@gmail.com\",\n\"dana@examplepetstore.com\",\n\"cloudysanfrancisco@gmail.com\"}\n`\n\n\n**Usage** : `$var1$.FILTER(~obj1-\u003e ~obj1.CONTAINS(\"@gmail.com\"))`\n\n\nFilter the string elements which contain *@gmail.com* in *var1*.\n\n\n**Output** : `\n{\"222larabrown@gmail.com\",\"cloudysanfrancisco@gmail.com\"}`\n\nExample 2: Filter a JSON array.\n-------------------------------\n\n\n**Sample data**: \n\n```\n $var1$ = {\n \"citynames\": [\n {\n \"city\": \"Abbeville\",\n \"state\": \"Louisiana\"\n },\n {\n \"city\": \"Aberdeen\",\n \"state\": \"Maryland\"\n },\n {\n \"city\": \"Benicia\",\n \"state\": \"California\"\n },\n {\n \"city\": \"Chehalis\",\n \"state\": \"Washington\"\n },\n {\n \"city\": \"Aberdeen\",\n \"state\": \"Washington\"\n },\n {\n \"city\": \"Aberdeen\",\n \"state\": \"Mississippi\"\n },\n {\n \"city\": \"Cheektowaga\",\n \"state\": \"New York\"\n }\n ]\n}\n```\n\n\u003cbr /\u003e\n\n\n**Usage**: \n\n```\nvar1.citynames\n.FILTER(~obj1-\u003e \n ~obj1\n .GET_PROPERTY(\"city\")\n .EQUALS(\"Aberdeen\")\n)\n```\n\n\u003cbr /\u003e\n\n\nFilter the elements which have the city as *Aberdeen* in *var1*.\n\n\n**Output**: \n\n```\n [{\n \"city\": \"Aberdeen\",\n \"state\": \"Maryland\"\n },\n {\n \"city\": \"Aberdeen\",\n \"state\": \"Washington\"\n },\n {\n \"city\": \"Aberdeen\",\n \"state\": \"Mississippi\"\n }]\n```\n\n\u003cbr /\u003e\n\nExample 3: Filter a nested JSON array.\n--------------------------------------\n\n\n**Sample data**: \n\n```\n $var1$ =\n{\n \"products\": [\n {\n \"PA\": \"Integrations\",\n \"users\": [\n {\n \"name\": \"Ariel\",\n \"role\": [\n \"editor\",\n \"approver\"\n ]\n },\n {\n \"name\": \"Dana\",\n \"role\": [\n \"admin\",\n \"deployer\"\n ]\n },\n {\n \"name\": \"Lee\",\n \"role\": [\n \"viewer\"\n ]\n }\n ]\n },\n {\n \"PA\": \"Apigee\",\n \"users\": [\n {\n \"name\": \"Mahan\",\n \"role\": [\n \"editor\",\n \"admin\",\n \"deployer\"\n ]\n },\n {\n \"name\": \"Quinn\",\n \"role\": [\n \"invoker\"\n ]\n }\n ]\n },\n {\n \"PA\": \"Connectors\",\n \"users\": [\n {\n \"name\": \"Kiran\",\n \"role\": [\n \"invoker\",\n \"admin\",\n \"deployer\"\n ]\n },\n {\n \"name\": \"Sasha\",\n \"role\": [\n \"admin\"\n ]\n }\n ]\n }\n ]\n}\n```\n\n\u003cbr /\u003e\n\n\n**Usage**: \n\n```\n var1.products\n .FOR_EACH(~obj1 -\u003e\n ~obj1\n .SET_PROPERTY(\n ~obj1\n .GET_PROPERTY(\"users\")\n .FILTER(~obj2 -\u003e\n ~obj2\n .GET_PROPERTY(\"role\")\n .TO_STRING()\n .CONTAINS(\"admin\")\n )\n , \n \"users\"\n )\n ) \n```\n\n\u003cbr /\u003e\n\n\nFilter the elements which contain *admin* in *users* of *var1*.\n\n\n**Output**: \n\n```\n [{\n \"PA\": \"Integrations\",\n \"users\": [{\n \"name\": \"Dana\",\n \"role\": [\"admin\", \"deployer\"]\n }]\n }, {\n \"PA\": \"Apigee\",\n \"users\": [{\n \"name\": \"Mahan\",\n \"role\": [\"editor\", \"admin\", \"deployer\"]\n }]\n }, {\n \"PA\": \"Connectors\",\n \"users\": [{\n \"name\": \"Kiran\",\n \"role\": [\"invoker\", \"admin\", \"deployer\"]\n }, {\n \"name\": \"Sasha\",\n \"role\": [\"admin\"]\n }]\n }]\n```\n\n\u003cbr /\u003e\n\nRecommendation\n--------------\n\n- Learn how to add and configure a [Data Mapping task](/application-integration/docs/configure-data-mapping-task)"]]