如何根据“lastModified”值对json输出进行排序?我尝试过查看其他主题,但无法在jq中使用。此示例只是众多条目中的一个。
我试过jq -s '.[].items |= sort_by(.lastModified)'
,但它不工作。
.items数组中的每个项目都应该根据“lastModified”值按日期排序,这样在输出中它们就会从最旧到最新列出。
[
{
"items": [
{
"id": "Y29tbW9KJHDGGViZjdihjdfgJDHF72Q2NNlNTE4MQ",
"repository": "files",
"format": "raw",
"group": "/artifactory",
"name": "artifactory/jfrog-artifactory-cpp-ce-7.68.14.rpm",
"version": null,
"assets": [
{
"downloadUrl": "https://nexusrepo.com/repository/files/artifactory/jfrog-artifactory-cpp-ce-7.68.14.rpm",
"path": "artifactory/jfrog-artifactory-cpp-ce-7.68.14.rpm",
"id": "MKUKYTGkNTEFYGidfUDFWQ4Mw",
"repository": "files",
"format": "raw",
"checksum": {
"sha1": "f7ff96bc6c0cc6ca6163a61635b",
"sha256": "97c152220522a2b91032f3a884313a88431a4371a4ef22e2e517cb3b",
"sha512": "52d225b9d3a35ef800b556e20067452c7b225b9d3a35ef80066173850c24bd4",
"md5": "63044d747d7e5b0c59436"
},
"contentType": "application/x-rpm",
"lastModified": "2023-10-18T12:59:48.331+00:00",
"lastDownloaded": "2023-10-26T09:34:14.859+00:00",
"uploader": "user",
"uploaderIp": "10.30.55.12",
"fileSize": 1273649726,
"blobCreated": null
}
]
}
],
"continuationToken": null
}
字符串
]
1条答案
按热度按时间wmvff8tz1#
结果是:
字符串