gpt4 book ai didi

json - 如何使用jq按日期时间字段排序?

转载 作者:行者123 更新时间:2023-12-04 17:43:23 25 4
gpt4 key购买 nike

[
{
"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"(上面只有一个项目-只是一个示例)进行排序?

最佳答案

jq 方法:

jq '.[].items |= sort_by(.lastTimestamp)' input.json

引用: jq Manual (development version)

关于json - 如何使用jq按日期时间字段排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50741593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com