【发布时间】:2021-04-27 19:48:47
【问题描述】:
在 json 中有一些我想按日期排序的记录,但是在尝试时会出现以下错误
dates.json
[
{
"lastScalingAt": "2020-12-11T17:29:35.888Z",
"lastConfigChangeAt": "2020-12-11T17:29:35.888Z"
},
{
"lastScalingAt": "2020-12-11T17:29:38.655Z",
"lastConfigChangeAt": "2020-12-11T17:29:38.655Z"
},
{
"lastScalingAt": "2020-12-11T17:29:37.233Z",
"lastConfigChangeAt": "2020-12-11T17:29:37.233Z"
},
{
"lastScalingAt": "2020-12-08T20:42:09.990Z",
"lastConfigChangeAt": "2020-03-30T16:23:59.682Z"
}
]
我试过这个:
jq '.[] | .lastConfigChangeAt | sort_by(.lastConfigChangeAt)' dates.json
错误: jq:错误(在:17):无法迭代字符串(“2020-12-11 ...)
我尝试了不同的方法,但找不到可能出错的地方
【问题讨论】:
标签: json date sorting format jq