Reputation: 13
I am looking for way to convert array of objects as mentioned in example below to just an object using jq
.
{
"appName": "ABC",
"target": [{
"connectedApp_SalesforceServiceCloud": "false"
},
{
"connectedApp_SalesforceSalesCloud": "false"
},
{
"connectedApp_DataDotcom": "true"
},
{
"connectedApp_SalesforceChatter": "true"
}
]
}
O/p Expected :
{
"appName": "ABC",
"target": {
"connectedApp_SalesforceServiceCloud": "false",
"connectedApp_SalesforceSalesCloud": "true",
"connectedApp_DataDotcom": "true",
"connectedApp_SalesforceChatter": "true"
}
}
Upvotes: 1
Views: 782
Reputation: 85683
You could just add
the array of objects together. Use the |=
operator to write it back to .target
itself
jq '.target |= add'
Upvotes: 4