Contact Us 1-800-596-4880

unionItems

unionItems(t: Type): Array<Type>

Returns an array of all the types that define a given Union type. This function fails if the input is not a Union type.

Introduced in DataWeave version 2.3.0.

Parameters

Name Description

t

The type to check.

Example

This example shows how unionItems behaves with different inputs.

Source

%dw 2.0
import * from dw::core::Types
type AType = String | Number
output application/json
---
{
   a: unionItems(AType)
}

Output

{
  "a": ["String","Number"]
}