azure-logic-appsbackslashjson-arrayagg

Replace Backslash when converting to JSON Array in Azure Logic App


I am trying to fetch a JSON Array, however the Logic App Response it itself is appending a backslash to the response. Output expected :- { "ABC": [ "000D", "100D", "1200D" ] } I am getting response like below picture

I am trying to use Replace function but it is not allowing to have replace function for array output. Any help is appreciated.

Thanks


Solution

  • You can do it like this ...

    Test Flow

    Test Flow

    The expression in that second step is ...

    json(replace(string(variables('JSON')), '\"', ''))
    

    ... which in simple terms is doing the following ...

    1. Converting the object to a string.
    2. Replacing all of the escaped quotes with an empty string.
    3. Converting the string back to a JSON object.

    Result

    Result