azure-logic-apps

azure logicapps dynamic expression


I need help , I need to extract values from below event out put and form a new json object , can any one help ? this is an array json ,

[{"data":{"order_in":{"st_details":[{"is_fin": "true","parent__id": "sometext","st_info":{"TID":"somevalie"},"name":"Completed","status":"Completed"}]}}}]

the new json object looks like this

{"or_information": {"details":[{"final": "@extracted dynamic values']}","id": "@extracted values","specific_info":{"TicketID":"@extracted values"},{"id":"","@extracted values":""}],"name":"@extracted values","status":"@extracted values"}]}}

Solution

  • You can change it using below design:

    Here, I have used Parse Json to get the values from Json:

    Input (Taken your input) is in Compose:

    enter image description here

    Parse Json Schema

    {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "data": {
                    "type": "object",
                    "properties": {
                        "order_in": {
                            "type": "object",
                            "properties": {
                                "st_details": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "is_fin": {
                                                "type": "string"
                                            },
                                            "parent__id": {
                                                "type": "string"
                                            },
                                            "st_info": {
                                                "type": "object",
                                                "properties": {
                                                    "TID": {
                                                        "type": "string"
                                                    }
                                                }
                                            },
                                            "name": {
                                                "type": "string"
                                            },
                                            "status": {
                                                "type": "string"
                                            }
                                        },
                                        "required": [
                                            "is_fin",
                                            "parent__id",
                                            "st_info",
                                            "name",
                                            "status"
                                        ]
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "required": [
                "data"
            ]
        }
    }
    

    Then:

    enter image description here

    Then:

    enter image description here

    Compose 1:

    enter image description here

    {
      "or_information": {
        "details": [
          {
            "final": "@{items('For_each')?['is_fin']}",
            "id": "@{item()?['parent__id']}",
            "specific_info": {
              "TicketID": "@{item()?['st_info']?['TID']}"
            }
          },
          {
            "id": "",
            "value": "@{item()?['parent__id']}"
          }
        ],
        "name": "@{item()?['name']}",
        "status": "@{item()?['status']}"
      }
    }
    

    Output:

    enter image description here

    enter image description here