Boolean
Within JSONata there are two types of Boolean expressions used to find out whether the result is true or false, namely:
Boolean operators that include
and,orBoolean functions that include:
Configuration
(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
=@ctx.datasources.employee.name = "Mary Gomez" ? true :false
(If value <) If the age of an employee is smaller than 20 set true.
=@ctx.datasources.employee.age < 20 ? true :false
(If array >) Does the array of data contain more than two objects?
=$count(@ctx.datasources.employees) > 2 ? true :false
Examples and code snippets
Evaluating fields

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 GitHub.
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 GitHub.
See tips and tricks when using placeholders for additional information.

Last updated
Was this helpful?