toArray

toArray(@StreamCapable text: String): Array<String>

Splits a String value into an Array of characters.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

text

The String value to transform into an Array of characters (a Array<String> type).

Example

This example shows how toArray behaves with different inputs.

Source

%dw 2.0
import * from dw::util::Coercions
output application/json indent=false
---
{
  a: toArray(""),
  b: toArray("hola")
}

Output

{"a": [],"b": ["h","o","l","a"]}

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub