Skip to content

Booleans ​

boolean applies JSONata truthiness (empty strings, 0, empty arrays/objects are false); not negates it; exists is true for any value that isn't undefined (including null).

boolean ​

boolean(value: unknown): boolean

JSONata truthiness: "", 0, [] and {} are false.

typeflow
hasBio: boolean(user.bio)

not ​

not(value: unknown): boolean

Negated JSONata truthiness.

typeflow
isBlank: not(user.bio)

exists ​

exists(value: unknown): boolean

True unless the value is undefined (null exists).

typeflow
wasDeleted: exists(user.deletedAt)

Playground ​

Mapping✔Playground ↗
Input JSON
Output
{
  "hasBio": false,
  "hasTags": true,
  "isBlank": true,
  "wasDeleted": true
}
inferred type{ hasBio: boolean; hasTags: boolean; isBlank: boolean; wasDeleted: boolean; }

Released under the MIT License.