@itentialopensource/filter-array-of-objects
v0.1.11-2023.1.1
Published
[Deprecated] Allows you to filter any array of objects by providing a key and a value to match on, and the option to discard the matching items from the array.
Downloads
4
Readme
Deprecation Notice
This Pre-Built has been deprecated as of 01-15-2024 and will be end of life on 01-15-2025. The capabilities of this Pre-Built have been replaced by the IAP - Data Manipulation
Filter Array of Objects
Table of Contents
Overview
This Pre-Built Transformation allows you to filter any array of objects by providing a key and a value to match on, and the option to discard the matching items from the array.
Installation Prerequisites
Users must satisfy the following pre-requisites:
- Itential Automation Platform
^2022.1.x
How to Install
To install the artifact:
- Verify you are running a supported version of the Itential Automation Platform (IAP) as listed above in the Requirements section in order to install the artifact.
- The artifact can be installed from within App-Admin_Essential. Simply search for the name of your desired artifact and click the install button.
How to Run
To use this JST, provide an array of objects as an input. Also provide a key and a value to find. Lastly, choose whether you want to discard or keep changes.
For example, this will return all the object matching key "state" and value "GA":
{
"filterableArray": [
{"city":"Atlanta", "state":"GA"},
{"city":"Sandy Springs", "state":"GA"},
{"city":"Dallas", "state":"TX"},
{"city":"Orlando", "state":"FL"}
],
"keyToFilterOn": "state",
"valueToFind": "GA",
"discardMatching": false
}
Output:
{
"filteredArray": [
{
"city": "Atlanta",
"state": "GA"
},
{
"city": "Sandy Springs",
"state": "GA"
}
],
"firstFilteredElement": {
"city": "Atlanta",
"state": "GA"
}
}