coderz.py

Keep Coding Keep Cheering!

Content Length Metadata Selector (.^contentLength)

In the following Mule app flow, the Logger uses payload.^contentLength to select the length of the string my string, set in the Set Payload (set-payload) component.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Metadata Selector (.^someMetadata)

Returns the value of specified metadata for a Mule payload, variable, or attribute.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Filter Selectors (myKey[?($ == “aValue”)])

myKey[?($ == “aValue”)] returns only the values of matching keys within an array or object. Note that ? is also used in Key Present Validator. If no key-value pairs match, the result is null.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Selector Modifiers (!, ?)

You can check for the presence of a given key.
! evaluates the selection and fails with an exception message if the key is not present.

? returns true if the selected key is present, false if not. Note that ? is also used in
Filter Selectors (myKey[?($ == “aValue”)]).

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Namespace Selector (#)

# returns the XML namespace of a selected key as plain text.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

XML Attribute Selector (.@myKey)

Using .@ without the key name returns an object containing the attributes as key-value pairs.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Range selector (anIndex to anotherIndex)

If you need multiple sequential values from an Array, DataWeave allows you to select a range of values with the range selector ([n to m]).

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Index Selector ([])

The index selector returns the element at the specified position. It can be applied over an array, object, or string.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Key-Value Pair Selector (.&myKey)

The & selector acts on arrays and objects. & retrieves both the keys and values of all matching keys pairs in the current context. These are returned as an object, containing the retrieved keys and values.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Descendants Selector (..)

The descendants selector (..) is the perfect tool to use when you need the values for a certain key no matter where they appear in a piece of data.

November 21, 2021 | Dataweave, Mule 4, Mulesoft | No comments

Advertisement