Contact Us 1-800-596-4880

toBoolean

toBoolean(str: String): Boolean

Transform a String value into a Boolean value.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

str

The String value to transform into a Boolean value.

Example

This example shows how toBoolean behaves with different inputs.

Source

%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
  a: toBoolean("true"),
  b: toBoolean("false"),
  c: toBoolean("FALSE"),
  d: toBoolean("TrUe")
}

Output

{
  "a": true,
  "b": false,
  "c": false,
  "d": true
}