DataWeave — Tip #4

There are times when you need to get one particular element from an array, but not based on the index. This item needs to fulfill some requirements like equality and so on. In order to perform that task selector, “?” was introduced. This is applicable for both DataWeave 1.0 and 2.0.

Syntax

Below, you can find the syntax for selecting an element of an array by a condition. This operation accepts array as an input and returns array as well. In the square brackets, we specify a condition that item needs to fulfill. First, we use the selector “?” sign, and after that, in parenthesis, we put condition. In order to check something against item property, we can use “$” variable to access the item. If we would like to get the item by isAvailable property, we would write something like this: $.isAvailable. https://goo.gl/iLThAU #DataIntegration #ML

Subscribe To Newsletter

Sign up for my newsletter and get the latest technology news

2019 © Craig Brown PhD. All rights reserved.