0

I need to extract values from below event output and form a new json object; can anyone help?

this is the 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"}]}}
2
  • 2
    Show us an attempt and we can help you out. Commented Apr 13 at 9:03
  • Did you try it using Parse Json? Commented Apr 14 at 3:39

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

3 Comments

Hello, thanks for your response and detailed solution , will trye that , sure it will work . one more query in that pay load this is an array in the section "provisioning_system_attributes" property , will multiple items would add autometically or need other expressions for that array items , these values will like like { "id": "Order id ", "value": "1327974733282287616" },{ "id": "Order id ", "value": "1327974733282287616" } kindly help
Please open a new question for new query. The community will help
yeah thanks, that solution works perfectly .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.