jsonazureparsinglogic

How do I extract values from an array Azure EventGrid Event Body receiver and format json object


I need help. I am trying to extract some values from an event grid receiver EventBody which is an Array and Compose a json object payload. my up roach is to parse the event body to json and using Parse Json. compose a json body object which I wanted to use to post to cosmos db, but I am unable to do that. here is the images to understand it better what I am trying. azure components used

Parse Event Data Connecter and Schema Parse schema

want to format json object like this

this dynamic expression is not giving expected results

can any one help?


Solution

  • This is the JSON you've given,

    {
      "data": {
        "or_information": {
          "details": [
            {
              "final": "some value",
              "TicketID": "TCK123"
            }
          ]
        }
      }
    }
    

    Here,

    The expression you've used,

    body('Parse_Event_Data')?['data']?['or_information']?[0]?['details']?[0]?['final']
    

    You're using ['or_information']?[0] , but or_information is not an array - it's an object, that [0] should not be there.

    So, replace your expression with following ,

    body('Parse_Event_Data')?['data']?['or_information']?['details']?[0]?['final']
    

    Now use compose or create JSON to build your output object and send that object to Cosmos DB

    Check this doc to learn about workflow expression functions in Azure Logic Apps and Power Automate.