Filter JSON LineItems in Logic App

Pavan G 186 Reputation points
2023-01-06T07:47:00.66+00:00

Hi Experts,

I have a requirement to make an API call by reading the PlanningMarketCode from the JSON. If the response is valid then pass the line item to the next step which is mapping else I need to ignore that line item for my mapping. I am somehow a bit confused about how to achieve this.

Source JSON:
276725-sourcejson.txt

From the attached JSON,

  1. Need to read the JSON path of the PlanningMarketCode value
  2. I need to filter the segments which have the codes 1044 and 1045 which are valid.

Any help/lead will be really grateful.

Regards,
Pavan

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
0 comments No comments
{count} votes

Answer accepted by question author
  1. MayankBargali-MSFT 70,986 Reputation points Moderator
    2023-01-06T14:05:07.38+00:00

    @Pavan G Thanks for reaching out. Logic app does provide filter array that can help you with your use case. For more details on filter array and Parse Json action please refer to this document. You need to first parse your JSON value using Parse Json action and for individual values (1044 and 1045) you need to leverage individual filter array to get your desire result. You can refer to expression function in logic app to know more details on the available functions

    Code View:

     "Filter_array": {  
                    "inputs": {  
                        "from": "@body('Parse_JSON')?['data']?['orderLineShipments']",  
                        "where": "@equals(item()?['orderReference']['orderReferenceAttributes'][3]['value'], '1044')"  
                    },  
                    "runAfter": {  
                        "Parse_JSON": [  
                            "Succeeded"  
                        ]  
                    },  
                    "type": "Query"  
                },  
                "Filter_array_2": {  
                    "inputs": {  
                        "from": "@body('Parse_JSON')?['data']?['orderLineShipments']",  
                        "where": "@equals(item()?['orderReference']['orderReferenceAttributes'][4]['value'], '1045')"  
                    },  
                    "runAfter": {  
                        "Filter_array": [  
                            "Succeeded"  
                        ]  
                    },  
                    "type": "Query"  
                },  
    

    Workflow:
    276941-image.png

    **Note: ** The above is only for reference and please modify/test it as per your needs.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.