Boolean

Within JSONata there are two types of Boolean expressions used to find out whether the result is true or false, namely:

Configuration

Result
Expression

(And) Does the array of data contain both a name and an image?

=$boolean(@ctx.datasources.employees.name and @ctx.datasources.employees.img)

(Or) Does the array of data contain a phone number or email?

=$boolean(@ctx.datasources.employees.phoneNumber or @ctx.datasources.employees.email)

(If value =) If the name of the employee is "Mary Gomez", set true

[email protected] = "Mary Gomez" ? true :false

(If value <) If the age of an employee is smaller than 20 set true.

[email protected] < 20 ? true :false

(If array >) Does the array of data contain more than two objects?

=$count(@ctx.datasources.employees) > 2 ? true :false

circle-exclamation

Examples and code snippets

Evaluating fields

Boolean expression
Boolean expression

This example evaluates static data in a component.enity to show the results in the entity field as a boolean.

See the full code sample in GitHubarrow-up-right.

Placeholder

Example of writing a condition for a placeholder. If the number of objects in the array is greater than zero, the placeholder is not displayed. If it isn't and the field is empty, a placeholder will appear with the icon and the specified text.

See the full code sample in GitHubarrow-up-right.

See tips and tricks when using placeholdersarrow-up-right for additional information.

Placeholder
Placeholder

Last updated

Was this helpful?