JmesPath找到不存在的地方

时间:2017-02-22 16:23:47

标签: jmespath

以下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"
    }
  ]
}

1 个答案:

答案 0 :(得分:3)

解决:括号是答案:

"Instances[?!(Tags[?Key=='team'])]"