jq - How to select objects based on a 'whitelist' of property values
问题 Since an example is worth a thousand words, say I have the following JSON stream: {"a": 0, "b": 1} {"a": 2, "b": 2} {"a": 7, "b": null} {"a": 3, "b": 7} How can I keep all the objects for which the .b property is one of [1, 7] (in reality the list is much longer so I don't want to do select(.b == 1 or .b == 7) ). I'm looking for something like this: select(.b in [1, 7]) , but I couldn't find what I'm looking for in the man page. 回答1: Doing $value in $collection could be achieved using the