I have a JSON input like that:
{
"details": [
{
"file": [
"xxx-abc"
],
"filePushedAt": "2021-10-25T09:31:39+02:00"
},
{
"file": [
"xxx-dfg"
],
"filePushedAt": "2021-11-08T16:24:05+01:00"
},
{
"file": [
"hij"
],
"filePushedAt": "2022-01-26T15:24:17+01:00"
},
{
"file": [
"xxx-klm"
],
"filePushedAt": "2022-01-27T15:24:18+01:00"
},
{
"file": [
"opr"
],
"filePushedAt": "2021-11-28T09:31:39+02:00"
}
]
}
Using JMESPath
I need to get the latest file (latest filePushedAt
) which consists xxx
prefix in file array.
I am able to extract files names in order by using
sort_by(details,& filePushedAt)[*].file[*]
but cannot complete the task. I'm wondering if it is even possible without jq
?