如果我有一个带有两个包含唯一值的数组的对象

{"all":["A","B","C","ABC"],"some":["B","C"]}

如何找到.all - .some

在这种情况下,我正在寻找["A","ABC"]

最佳答案

@Jeff Mercado令我震惊!我不知道允许数组减法...

echo -n '{"all":["A","B","C","ABC"],"some":["B","C"]}' | jq '.all-.some'

产量
[
  "A",
  "ABC"
]

关于jq - JQ:两个数组的setdiff,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29396154/

10-13 04:55