I have following JSON. I want to get key-value pair objects based on their CC role. In this example there are 3 roles(Presenter, Approver, Customer). Presenter is of type TO
. Other 2 are of type CC
. I want to get of type CC
. There can be more as it is dynamic.
JSON
{
"Presenter_TO_Email": "roney@domain.com",
"Approver_CC_Email": "tim@domain.com",
"Customer_CC_Email": "alex@domain.com",
"Invoice": "001",
"Date": "2022-02-14"
}
Output
{
"Approver": {
"email_address": "tim@domain.com",
"role": "Approver"
},
"Customer": {
"email_address": "alex@domain.com",
"role": "Customer"
}
}
I can do using INDEX using this example but as I am using older version of jq
, it throws error jq: error: INDEX/2 is not defined at <top-level>, line 1: