With jq
, how do I select all objects, which may be nested, with a desired value?
For example, given the following:
{
"a": "b",
"c": {
"d": {
"e": "f",
"z": "b"
}
}
}
How do I filter down to objects whose value is "b"
?
{
"a": "b",
"c": {
"d": {
"z": "b"
}
}
}
Conversely, how do I select objects whose value is not "b"
?
{
"c": {
"d": {
"e": "f"
}
}
}
I've attempted at the problem by using the select
and walk
functions, but could not get exactly what I wanted.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…