【发布时间】:2020-09-26 16:33:14
【问题描述】:
使用jq,按照最近的时间戳对数组中的对象数组进行排序,然后按照每个数组的第一个对象的时间戳对外部数组进行排序。
这是 JSON 数据的一个示例,位于我被卡住的 jq 管道阶段。
[
[
{
"created_at": "2020-09-26T14:48:46.000Z",
"conversation_id": "1309867515456237571",
"id": "1309867515456237571",
"text": "example1"
}
],
[
{
"created_at": "2020-09-26T14:48:47.000Z",
"conversation_id": "1309867518455156736",
"id": "1309867518455156736",
"text": "example2"
},
{
"created_at": "2020-09-26T14:48:47.000Z",
"conversation_id": "1309867518455156736",
"id": "1309867517846810625",
"text": "example3"
},
{
"created_at": "2020-09-26T14:48:46.000Z",
"conversation_id": "1309867518455156736",
"id": "1309867516659937284",
"text": "example4"
}
],
[
{
"created_at": "2020-09-26T14:48:48.000Z",
"conversation_id": "1309867524473999364",
"id": "1309867524473999364",
"text": "example5"
},
{
"created_at": "2020-09-26T14:48:47.000Z",
"conversation_id": "1309867524473999364",
"id": "1309867520468291586",
"text": "example6"
},
{
"created_at": "2020-09-26T14:48:47.000Z",
"conversation_id": "1309867524473999364",
"id": "1309867520153845760",
"text": "example7"
}
],
[
{
"created_at": "2020-09-26T14:48:48.000Z",
"conversation_id": "1309867524750749705",
"id": "1309867524750749705",
"text": "example8"
}
]
]
我尝试过的一切都以这样的错误告终,
jq: error (at <stdin>:8): Cannot index string with string "created_at"
【问题讨论】: