Filter out items from array based on count in subarray

Hello,
I have a http module that parses json into the structure you see in the image
as you can see there are 959 products and each product has a child that lists all the prices available for that product. So there are 7 prices available for product 130050

some products do not have any prices , then the totalCount will be 0 and the items array will be empty

I want to filter out any products where the joindown_PriceAndDiscountMatrix_via_Product.totalCount is 0 but I can’t get it to work.



in the json below I want to filter out product 900118 because it has no prices

{
    "data": {
        "useCompany": {
            "product": {
                "totalCount": 959,
                "items": [
                    {
                        "productNo": "130050",
                        "processingMethod7": 1,
                        "joindown_PriceAndDiscountMatrix_via_Product": {
                            "totalCount": 2,
                            "items": [
                                {
                                    "createdDate": 20211201,
                                    "lineNo": 22856,
                                    "productNo": "130050",
                                    "salesPrice1InCurrency": 132.45,
                                    "customerPriceGroup1": 1,
                                    "customerPriceGroup3": 0,
                                    "currencyNo": 99
                                },
                                {
                                    "createdDate": 20240924,
                                    "lineNo": 72116,
                                    "productNo": "130050",
                                    "salesPrice1InCurrency": 1437,
                                    "customerPriceGroup1": 126,
                                    "customerPriceGroup3": 0,
                                    "currencyNo": 46
                                }
                            ]
                        }
                    },
                    {
                        "productNo": "900118",
                        "processingMethod7": 1,
                        "joindown_PriceAndDiscountMatrix_via_Product": {
                            "totalCount": 0,
                            "items": null
                        }
                    }
                ]
            }
        }
    }
}
1 Like

Hi @tadrian

Could you please share the output bundle of http module so that we could further assist you.

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

1 Like

I updated the post with a sample

1 Like

Hi @tadrian
Sample workflow with the json structure you shared.





Now you will have array with items that has total count greater than 0

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

2 Likes

thanks, it worked!
I must have missed that I needed an iterator to filter

2 Likes

Hi @tadrian
Glad to know your issue is solved.

Best regards,
Msquare Automation
Platinum Partner of Make
@Msquare_Automation

1 Like