$cond

$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.

Syntax

{
    "$cond": [ <condition>, <true_val>, <false_val> ]
}

Properties

Returns

<object> - Returns either the <true_val> or <false_val> based on the condition. The object type can be anything based on the values provided.

Examples

With Magical Autocomplete

Let's say we have declared a variable country in our API flow, which has an array value of US currently.

{
    "$cond": [ 
        { "$eq": ["$.variables.country", "India"] },
        10,
        20
    ]
}

The above expression returns 20 as the condition becomes false.

Last updated