Filtering JSON objects with jq
I have a JSON file which contains unneeded values. I want to filter them by only selecting those I need, or deleting those I don’t need. For example, I have this JSON file:
{
{ "id" : "1",
"key1" : "val1",
"key2" : "val2",
"name" : "someone",
"age" : 39,
},
{ "id" : "1234",
"key1" : "val1",
"key2" : "val2",
"name" : "someone",
"age" : 39
},
{ "id" : "4567",
"key1" : "val1",
"key2" : "val2",
"name" : "someone",
"age" : 60
}
}
My aim is to get the following JSON, by deleting all key1 and key2 items recursively using a jq command:
{
{ "id" : "1",
"name" : "someone",
"age" : 39,
},
{ "id" : "1234",
"name" : "someone",
"age" : 39
},
{ "id" : "4567",
"name" : "someone",
"age" : 60
}
}
Thank you.
Read more here: Source link