Reputation: 642
I have following JSON input
{
"events": [
{
"cluster_id": "0717-035521-puny598",
"timestamp": 1535540053785,
"type": "TERMINATING",
"details": {
"reason": {
"code": "INACTIVITY",
"parameters": {
"inactivity_duration_min": "15"
}
}
}
},
{
"cluster_id": "0717-035521-puny598",
"timestamp": 1535537117300,
"type": "EXPANDED_DISK",
"details": {
"previous_disk_size": 29454626816,
"disk_size": 136828809216,
"free_space": 17151311872,
"instance_id": "6cea5c332af94d7f85aff23e5d8cea37"
}
}
]
}
I want to convert it into following.
1) add one static key:value in each object of "events" array. 2) remove one element "type" from each object of "events" array. 3) rest all values should be same in i/p and o/p. "details" is a object with no specific structure.
{
"events": [
{
"new_key" : "new_value",
"cluster_id": "0717-035521-puny598",
"timestamp": 1535540053785,
"details": {
"reason": {
"code": "INACTIVITY",
"parameters": {
"inactivity_duration_min": "15"
}
}
}
},
{
"new_key" : "new_value",
"cluster_id": "0717-035521-puny598",
"timestamp": 1535537117300,
"details": {
"previous_disk_size": 29454626816,
"disk_size": 136828809216,
"free_space": 17151311872,
"instance_id": "6cea5c332af94d7f85aff23e5d8cea37"
}
}
]
}
Upvotes: 0
Views: 159
Reputation: 12083
The following chain spec should work:
[
{
"operation": "default",
"spec": {
"events[]": {
"*": {
"new-key": "new-value"
}
}
}
},
{
"operation": "remove",
"spec": {
"events": {
"*": {
"type": ""
}
}
}
}
]
Upvotes: 1