Skip to main content

$toBoolean

The $toBoolean operator converts a value to a boolean.

Input

  • A single value of any type

Output

  • The boolean representation of the input value

Examples

Convert Number to Boolean

{
  "$toBoolean": [
    1
  ]
}
Result: true

Convert Zero to Boolean

{
  "$toBoolean": [
    0
  ]
}
Result: false

Convert String to Boolean

{
  "$toBoolean": [
    "true"
  ]
}
Result: true

From Field

{
  "$toBoolean": [
    {
      "$input": "value"
    }
  ]
}
Result: The boolean representation of the value field