6

以下 JmesPath 表达式查找已标记为团队的实例:

"Instances[?Tags[?Key=='team']]"

您知道如何查找未标记为团队的实例吗?

我努力了:

"Instances[?!Tags[?Key=='team']]"
-> !Tags[?Key=='team']]: event not found
"Instances[?null==Tags[?Key=='team']]"
-> []  <-- wrong answer
"Instances[?!not_null(Tags[?Key=='team'])]"
-> !not_null: event not found

提前谢谢了!

样本输入:

{ "Instances":
  [ { "id": "i-911"
    , "Tags":
      [ {"Key":"owner", "Value":"Edu"}
      , {"Key":"team", "Value":"forensics"}
      ]
    , "many other keys": "stuff"
    }
  , { "id": "i-999"
    , "Tags":
      [ {"Key":"owner", "Value":"Edu"}
      , {"Key":"note", "Value":"No team!"}
      ]
    , "many other keys": "stuff"
    }
  ]
}
4

1 回答 1

14

已解决:括号是答案:

"Instances[?!(Tags[?Key=='team'])]"
于 2017-02-22T18:08:14.693 回答