[
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "v1",
"count": 603,
"firstTimestamp": "2018-06-07T13:07:32Z",
"involvedObject": {
"apiVersion": "v1",
"kind": "Pod",
"name": "events-db8f675c6-khm4r",
"namespace": "default",
"resourceVersion": "2989590",
"uid": "bd489878-6a53-11e8-9351-0e5486765cbc"
},
"kind": "Event",
"lastTimestamp": "2018-06-07T16:02:52Z"
}
]
}
]
How could I sort all the items
(there is only one item above - but it's just an example) by the .items.lasttimestamp
value, for example the value "lastTimestamp": "2018-06-07T11:59:53Z"
?
jq
approach:
jq '.[].items |= sort_by(.lastTimestamp)' input.json
Reference: jq Manual (development version)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With