cancel
Showing results for 
Search instead for 
Did you mean: 

Filter object from array

Max
New Contributor II

Hello, I need to filter out an object from the distributionCenterSpecificData array where countryCodes array is empty.

input payload:

[{
            "rpn""ABCD",
            "gpn""G12345",
            "productName""CATHETER",
            "productDescription""EXTRA FIRM",
            "division""MedSurg",
            "sbu""CC",
            "productFamily""AIRWAY MANAGEMENT",
            "productSubFamily1""C-CAE",
            "productSubFamily2""NOT APPLICABLE",
            "productStatus""CURRENT",
            "program""CC",
            "madeby""CEW",
            "lastUpdatedDate""2024-02-08T00:00:50.000",
            "distributionCenterSpecificData": [
                {
                    "dcName""NADC",
                    "gtin""004011",
                    "uom""EA",
                    "quantity"1,
                    "availability""AVAILABLE",
                    "stockStatus""STOCK",
                    "currencyCode""USD",
                    "isActive""true",
                    "countryCodes": []
                },
                {
                    "dcName""CADC",
                    "gtin""004011",
                    "uom""EA",
                    "quantity"1,
                    "availability""AVAILABLE",
                    "stockStatus""STOCK",
                    "currencyCode""CAD",
                    "isActive""true",
                    "countryCodes": [
                        "CA"
                    ]
                }
            ]
        },
    {
            "rpn""XYZ",
            "gpn""G45678",
            "productName""GRAFT",
            "productDescription""SOFT",
            "division""Other",
            "sbu""TTX",
            "productFamily""COLORECTAL",
            "productSubFamily1""RECTOPEXY",
            "productSubFamily2""RECTOPEXY PLUG",
            "productStatus""CURRENT",
            "program""Other",
            "madeby""CEW",
            "lastUpdatedDate""2023-10-09T10:04:29.480",
            "distributionCenterSpecificData": [
                {
                    "dcName""NADC",
                    "gtin""104731",
                    "uom""BX",
                    "quantity"1,
                    "availability""AVAILABLE",
                    "stockStatus""STOCK",
                    "currencyCode""USD",
                    "isActive""true",
                    "countryCodes": [
                        "US"
                    ]
                }
            ]
        }
]
 
Expected output:
[{
            "rpn""ABCD",
            "gpn""G12345",
            "productName""CATHETER",
            "productDescription""EXTRA FIRM",
            "division""MedSurg",
            "sbu""CC",
            "productFamily""AIRWAY MANAGEMENT",
            "productSubFamily1""C-CAE",
            "productSubFamily2""NOT APPLICABLE",
            "productStatus""CURRENT",
            "program""CC",
            "madeby""CEW",
            "lastUpdatedDate""2024-02-08T00:00:50.000",
            "distributionCenterSpecificData": [
                {
                    "dcName""CADC",
                    "gtin""004011",
                    "uom""EA",
                    "quantity"1,
                    "availability""AVAILABLE",
                    "stockStatus""STOCK",
                    "currencyCode""CAD",
                    "isActive""true",
                    "countryCodes": [
                        "CA"
                    ]
                }
            ]
        },
    {
            "rpn""XYZ",
            "gpn""G45678",
            "productName""GRAFT",
            "productDescription""SOFT",
            "division""Other",
            "sbu""TTX",
            "productFamily""COLORECTAL",
            "productSubFamily1""RECTOPEXY",
            "productSubFamily2""RECTOPEXY PLUG",
            "productStatus""CURRENT",
            "program""Other",
            "madeby""CEW",
            "lastUpdatedDate""2023-10-09T10:04:29.480",
            "distributionCenterSpecificData": [
                {
                    "dcName""NADC",
                    "gtin""104731",
                    "uom""BX",
                    "quantity"1,
                    "availability""AVAILABLE",
                    "stockStatus""STOCK",
                    "currencyCode""USD",
                    "isActive""true",
                    "countryCodes": [
                        "US"
                    ]
                }
            ]
        }
]
1 ACCEPTED SOLUTION

SpiroTaleski
Valued Contributor

@Max 

You can achieve the transformation using filter function.

Find the attached sample pipeline. 

 

View solution in original post

1 REPLY 1

SpiroTaleski
Valued Contributor

@Max 

You can achieve the transformation using filter function.

Find the attached sample pipeline.