I am trying to flatten the "policy_metrics" array in the following JSON
{
"ticket": {
"url": "https://company.zendesk.com/api/v2/tickets/12107.json",
"id": 12107,
"description": "test",
"priority": "high",
"status": "open",
"slas": {
"policy_metrics": [
{
"breach_at": "2020-09-18T09:27:53Z",
"stage": "active",
"metric": "pausable_update_time",
"days": 2
},
{
"breach_at": null,
"stage": "achieved",
"metric": "first_reply_time"
},
{
"breach_at": "2020-09-16T09:18:56Z",
"stage": "achieved",
"metric": "next_reply_time",
"hours": -4
}
]
},
"allow_channelback": false,
"allow_attachments": true
}
}
When I use
$.ticket.slas.policy_metrics[*]
I get the following which is what I want.
- breach_at
- stage
- metric
- days
- hours
What I am not able to figure out is how to get the ticket attributes and the policy_metrics attributes. For example:
- url
- id
- description
- priority
- status
- breach_at
- stage
- metric
- days
- hours
If its not possible with JSONPath, example with Javascript will also work.
Thanks for your help.