【发布时间】:2021-11-20 16:20:14
【问题描述】:
我有这个 json 数据:
{
"results": [
{
"request": {
"metric": "CLOUDFREE_TIME_PERCENT",
"path": {
"fromPoint": {
"pointX": -94.2802,
"pointY": 23.6687,
"pointZ": 564843.0
},
"time": {
"seconds": 1582074350
},
"toPoint": {
"pointX": -118.2258,
"pointY": 33.7501,
"pointZ": -2.6077032e-08
}
},
"waveLength": 0
},
"response": {
"dataSources": [],
"metricValue": 0.0,
"success": false
}
},
{
"request": {
"metric": "CLOUDFREE_TIME_PERCENT",
"path": {
"fromPoint": {
"pointX": -20.6361,
"pointY": 16.1509,
"pointZ": 563070.9
},
"time": {
"seconds": 1582056949
},
"toPoint": {
"pointX": -20.6361,
"pointY": 16.1509,
"pointZ": 563070.9
}
},
"waveLength": 0
},
"response": {
"dataSources": [],
"metricValue": 0.0,
"success": false
}
},
{
"request": {
"metric": "CLOUDFREE_TIME_PERCENT",
"path": {
"fromPoint": {
"pointX": -94.2661,
"pointY": 23.6066,
"pointZ": 564826.16
},
"time": {
"seconds": 1582064349
},
"toPoint": {
"pointX": -118.2258,
"pointY": 33.7501,
"pointZ": -2.6077032e-08
}
},
"waveLength": 0
},
"response": {
"dataSources": [],
"metricValue": 0.0,
"success": false
}
}
]
}
我一直在尝试(但失败)按“秒”值对其进行排序。我试过jq '.results[].request.path.time|=sort_by(.seconds)' output.json,它给了我错误Cannot index number with string "seconds"。我已经尝试了对该命令的各种重新排列(以及用map() 包装它之类的东西)也无济于事。我开始怀疑这是否可能。任何帮助将不胜感激!
【问题讨论】: