[
{
"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"
}
]
}
]
我如何按items
值对所有.items.lasttimestamp
(上面只有一个项目 - 但只是一个示例)进行排序,例如值"lastTimestamp": "2018-06-07T11:59:53Z"
?
答案 0 :(得分:5)
jq
方法:
jq '.[].items |= sort_by(.lastTimestamp)' input.json