if
TABLE OF CONTENTS
Execute an action depending on whether a condition is met
Definition
any if(any $condition, any $trueValue, any $falseValue)
Returns $trueValue if $condition is truthy and $falseValue if $condition is falsy.
Parameters
any $condition
The value to evaluate the truthfulness of.
any $trueValue
The value to return in case $condition evaluates to true.
any $falseValue
The value to return in case $condition evaluates to false.
Returns
any
$trueValue or $falseValue, depending on the Boolean value of $condition.
Examples
Transformation
{
a: if(`true`, '1', '0'),
b: if(`false`, '1', '0'),
c: if('foo', '1', '0'),
d: if(`null`, '1', '0'),
e: if([`0`,`1`], '1', '0')
}Result
{
"a": "1",
"b": "0",
"c": "1",
"d": "0",
"e": "1"
}Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article