Reputation: 759
I have this json (simplified) coming from a REST api:
{
"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"
}
}
}
]
}
How I can sort it based status-timestamps.planned-at
?
Among other things I tried this jq '[.data[].attributes | sort_by(.status-timestamps.planned-at) ]'
Upvotes: 0
Views: 68
Reputation: 26592
Does this achieve what you wanted ?
jq '.data |= sort_by(.attributes."status-timestamps"."planned-at")'
Upvotes: 1