I have the following json:
[
{
"SG": [
{
"Id": "17",
"GroupName": "fistGN",
"Permissions": [
{
"Port": 80,
"Protocol": "tcp"
},
{
"Port": 8080,
"Protocol": "tcp"
},
{
"Port": 5080,
"Protocol": "tcp"
}
]
},
{
"Id": "1",
"GroupName": "secondGN",
"Permissions": [
{
"Port": 80,
"Protocol": "tcp"
},
{
"Port": 8080,
"Protocol": "tcp"
},
{
"Port": 5080,
"Protocol": "tcp"
}
]
}
]
}
]
Is it possible to sort_by GroupName and then for each group by Permissions Port using a single command?
This is what I'm trying to do but that is not working as expected:
jq -s -S '.[].SG |= sort_by(.GroupName, .Permissions[].Port)' myfile.json