$cond
Last updated
$cond operator lets you build conditions directly in CQL and returns you the item based on the condition passed in the object. You can use this in any Expression Object.
{
"$cond": [ <condition>, <true_val>, <false_val> ]
}<condition>
The <condition> can be any valid condition object as long as it resolves to a boolean object.
It can also be a Magical Autocomplete.
true
<true_val>
The value to return if the <condition> resolves to true.
It can also be a Magical Autocomplete.
true
<false_val>
The value to return if the <condition> resolves to false.
It can also be a Magical Autocomplete.
true
<object> - Returns either the <true_val> or <false_val> based on the condition. The object type can be anything based on the values provided.
Let's say we have declared a variable country in our API flow, which has an array value of US currently.
The above expression returns 20 as the condition becomes false.
Last updated
{
"$cond": [
{ "$eq": ["$.variables.country", "India"] },
10,
20
]
}