Input:
{
"data": {
"assets": [{
"organizationId": "1056bda9-2598-4fdf-bd99-db3924464a75",
"createdAt": "2018-03-14T14:41:41.154Z",
"tags": [{
"value": "raml",
"key": null,
"mutable": false
},
{
"value": "rest",
"key": null,
"mutable": false
},
{
"value": "api",
"key": null,
"mutable": false
},
{
"value": "v1",
"key": "product-api-version",
"mutable": false
},
{
"value": "has-mule4-connector",
"key": null,
"mutable": false
},
{
"value": "has-mule3-connector",
"key": null,
"mutable": false
},
{
"value": "system",
"key": null,
"mutable": true
},
{
"value": "sourcing",
"key": null,
"mutable": true
}
],
"type": "rest-api"
},
{
"organizationId": "SASAAs",
"createdAt": "2018-03-14T14:41:41.154Z",
"tags": [{
"value": "raml",
"key": null,
"mutable": false
},
{
"value": "rest",
"key": null,
"mutable": false
},
{
"value": "api",
"key": null,
"mutable": false
},
{
"value": "v1",
"key": "product-api-version",
"mutable": false
},
{
"value": "has-mule4-connector",
"key": null,
"mutable": false
},
{
"value": "has-mule3-connector",
"key": null,
"mutable": false
},
{
"value": "system",
"key": null,
"mutable": true
},
{
"value": "supply-chain",
"key": null,
"mutable": true
}
],
"type": "rest-api"
}
]
}
}
Expected output:
{
"data": {
"assets": [{
"organizationId": "1056bda9-2598-4fdf-bd99-db3924464a75",
"createdAt": "2018-03-14T14:41:41.154Z",
"tags": [{
"value": "raml",
"key": null,
"mutable": false
},
{
"value": "rest",
"key": null,
"mutable": false
},
{
"value": "api",
"key": null,
"mutable": false
},
{
"value": "v1",
"key": "product-api-version",
"mutable": false
},
{
"value": "has-mule4-connector",
"key": null,
"mutable": false
},
{
"value": "has-mule3-connector",
"key": null,
"mutable": false
},
{
"value": "system",
"key": null,
"mutable": true
},
{
"value": "sourcing",
"key": null,
"mutable": true
}
],
"type": "rest-api",
"domain": "sourcing"
},
{
"organizationId": "SASAAs",
"createdAt": "2018-03-14T14:41:41.154Z",
"tags": [{
"value": "raml",
"key": null,
"mutable": false
},
{
"value": "rest",
"key": null,
"mutable": false
},
{
"value": "api",
"key": null,
"mutable": false
},
{
"value": "v1",
"key": "product-api-version",
"mutable": false
},
{
"value": "has-mule4-connector",
"key": null,
"mutable": false
},
{
"value": "has-mule3-connector",
"key": null,
"mutable": false
},
{
"value": "system",
"key": null,
"mutable": true
},
{
"value": "supply-chain",
"key": null,
"mutable": true
}
],
"type": "rest-api",
"domain": "supply-chain"
}
]
}
}
SO far, I tried this which worked partially for me.
.data.assets[] | select (.tags[].value=="sourcing") | . += {"domain":"sourcing"}
The problem is that I want this condition to apply for every object inside the array but I'm not able to do that. It is getting applied to the first object only.
Where am i doing wrong? Any suggestions please?