How can I get the first x levels of depth of an object and remove the rest using jq ?
I have the following example:
{
"Service1": {
"Production": {
"Location 1": {
"b2d1": {
"clusters": {
"Datacenter2": []
},
"prod": {
"clusters": {
"Datacenter1": []
}
}
}
},
"Service2": {
"Production": {
"Location 1": {
"dr1": {
"clusters": {
"Datacenter3": []
},
"prod": {
"clusters": {
"Datacenter1": []
}
}
}
}
}
}
}
}
}
In my case, I want to get the 1st 3 levels (want to remove everything bellow location in all entries.