Working with Objects

Objects (dw::core::Objects)

This module contains helper functions to work with Objects.

It processes both keys and values as a tuple.

To use this module, you must import it to your DataWeave code, for example, by adding the line import * from dw::core::Objects to the header of your DataWeave script.

We will start with a brief review of filterObject, used to remove key-value pairs from an Object based on some criteria much like filter is used in Arrays.

We’ll then discuss mapObject, which is used to transform every key-value pair into something else.

We’ll also go over pluck, a function that goes from Objects to Arrays and is very useful when combined with the groupBy function we learned on the previous tutorial.

Functions

NameDescription
divideByBreaks up an object into sub-objects that contain the specified number of key-value pairs.
entrySetReturns an array of key-value pairs that describe the key, value, and any attributes in the input object.
everyEntryReturns true if every entry in the object matches the condition.
keySetReturns an array of key names from an object.
mergeWithAppends any key-value pairs from a source object to a target object.
nameSetReturns an array of keys from an object.
someEntryReturns true if at least one entry in the object matches the specified condition.
takeWhileSelects key-value pairs from the object while the condition is met.
valueSetReturns an array of the values from key-value pairs in an object.

Follow Me

If you like my post please follow me to read my latest post on programming and technology.

Instagram

Facebook

Recent Posts

Generate Parenthesis | Intuition + Code | Recursion Tree | Backtracking | Java

Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…

3 months ago

Square Root of Integer

Given an integer A. Compute and return the square root of A. If A is…

1 year ago

Build Array From Permutation

Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…

1 year ago

DSA: Heap

A heap is a specialized tree-based data structure that satisfies the heap property. It is…

2 years ago

DSA: Trie

What is a Trie in DSA? A trie, often known as a prefix tree, is…

2 years ago

Trees: Lowest Common Ancestor

What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…

2 years ago