{
"a": "green",
"b": "white"
}
{
"a": "red",
"c": "purple"
}
into one object:
{
"a": "red",
"b": "white",
"c": "purple"
}
Also, how can I wrap the same sequence into an array?
[
{
"a": "green",
"b": "white"
},
{
"a": "red",
"c": "purple"
}
]
Thus one way to combine objects in the input stream is to use:
jq -s add
For the second problem, creating an array:
jq -s .
cat allips.json
{
"last": true,
"totalElements": 3898,
"totalPages": 1,
"first": true,
"numberOfElements": 3898,
"size": 9999,
"number": 0,
"content": [
{
"ip": "9.135.64.10",
"policy": 0,
"updateTime": "2020-12-30T13:35:42.327160012Z",
"releasable": true
},
{
"ip": "9.135.64.100",
"policy": 0,
"updateTime": "2020-12-30T13:43:43.059217922Z",
"releasable": true
},
{
"ip": "9.135.64.101",
"policy": 0,
"updateTime": "2020-12-30T13:47:20.33446172Z",
"releasable": true
}]
}
cat allips.json | jq '.content[]| select( .releasable == true and .status == "Deleted" )|{ip: .ip, appType: .appType, appName: .appName, podName: .podName, namespace: .namespace}' | jq -s '{ips:.}'