寻找 jq 过滤器以根据嵌套 属性 的值排除嵌套对象

Looking for a jq filter to exclude nested objects based on the value of a nested property

鉴于此输入:

{
  "10000703": {
    "show_id": 1641788,
  },
  "10000838": {
    "show_id": 1517903,
  },
  "10001325": {
    "show_id": 1641788,
  },
}

我正在寻找一个过滤器说 "return all objects where show_id does not equal 1641788"

预期输出为:

{
  "10000838": {
    "show_id": 1517903,
  },
}

无法排除嵌套对象:(

这是一个很好的例子,说明了 with_entries/1 的便利性和 jq 的简洁性:

with_entries( select(.value.show_id != 1641788 ))

with_entries/1 将对象转换为明确的 .key/.value 表示。详情请见jq manual

或者更简洁,在这种情况下也可以使用 del/1:

del( .[] | select( .show_id == 1641788 ) )