Logic App : Finding element in Json Object array (like XPath fr XML)

Chris Hammond picture Chris Hammond · Jul 31, 2018 · Viewed 7.4k times · Source

In my logic app, I have a JSON object (parsed from an API response) and it contains an object array.

How can I find a specific element based on attribute values... Example below where I want to find the (first) active one

{
    "MyList" : [
        {
            "Descrip" : "This is the first item",
            "IsActive" : "N"
        },
        {
            "Descrip" : "This is the second item",
            "IsActive" : "N"
        },
        {
            "Descrip" : "This is the third item",
            "IsActive" : "Y"
        }
   ]
}

Answer

Chris Hammond picture Chris Hammond · Aug 1, 2018

Well... The answer is in plain sight ... There's a FILTER ARRAY action, which works on a JSON Object (from PARSE JSON action).. couple this with an @first() expression will give the desired outcome.

enter image description here