jmespath.site icon indicating copy to clipboard operation
jmespath.site copied to clipboard

filter on key containing special character

Open fmoor opened this issue 7 years ago • 0 comments

Data Structure

{
  "objects": [
    {
      "@TYPE": A,
      "$": "one",
    },
    {
      "@TYPE": B,
      "$": "two",
    },
    {
      "@TYPE": C,
      "$": "three",
    }
  ]
}

Question

I am trying to write a query that will return "one". I have tried the following: objects[?@TYPE == "A"]."$" this is a syntax error objects[?"@TYPE" == "A"]."$" this returns an empty array objects[?"\@TYPE" == "A"]."$" this is a syntax error objects[?"/@TYPE" == "A"]."$" this returns ["one", "two", "three"] which is a surprise...

What is the proper way to escape the @ in the key name?

fmoor avatar Feb 12 '18 18:02 fmoor