json - 用 jq 对 json 进行排序
问题描述
我有这个来自 REST api 的 json(简化):
{
"data": [
{
"id": "run-bWSq4YeYpfrW4mx7",
"type": "runs",
"attributes": {
"source": "tfe-configuration-version",
"status": "planned",
"status-timestamps": {
"planned-at": "2017-11-28T22:52:51+00:00"
}
}
},
{
"id": "run-bWSq4YeYpfrW4ft7",
"type": "runs",
"attributes": {
"source": "tfe-configuration-version",
"status": "planned",
"status-timestamps": {
"planned-at": "2017-11-28T21:52:51+00:00"
}
}
}
]
}
我怎样才能对它进行排序status-timestamps.planned-at
?
除其他外,我尝试了这个jq '[.data[].attributes | sort_by(.status-timestamps.planned-at) ]'
解决方案
这是否达到你想要的?
jq '.data |= sort_by(.attributes."status-timestamps"."planned-at")'
推荐阅读
- android - 数据未通过 volley 传递到服务器
- javascript - Javascript .innerHTML 但不包括内部 div
- javascript - React JS无限滑块问题
- android - Recyclerview 在其他视图
- java - 在 Thymeleaf 中使用 DateFormat.SHORT
- java - 将文件下载到我们正在执行 API 的系统中
- jenkins - 无法在 jenkins Over Kubernetes 中安装插件
- jquery - google-apps-script Web 应用程序中的模板
- python - 我想迭代一个 JSON 对象,该对象在 python 中具有更改的键名
- sql - 如何为飞行路线迁移添加评论