index

index(index: Number): PathElement

This function creates a PathElement data type to use for selecting an array element and populates the type’s selector field with the specified index.

Some versions of the update and mask functions accept a PathElement as an argument.

Introduced in DataWeave version 2.2.2.

Parameters

Name Description

index

The index.

Example

This example creates an selector for a specified index. It sets the selector’s value to 0. In the output, also note that the value of the "kind" key is "Array".

Source

%dw 2.0
output application/json
import * from dw::util::Values
ns ns0 http://acme.com/foo
---
index(0)

Output

{
   "kind": "Array",
   "namespace": null,
   "selector": 0
 }

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub