jmespath

Does JMESPath have an identity function?


In the jq filtering language the . filter expression simply returns the input JSON unaltered (except for pretty printing). E.g.

$ echo '{"foo": true, "bar": 42}' | jq '.'
{
  "foo": true,
  "bar": 42
}

Does JMESPath have a similar expression (aka identity function)?


Solution

  • The current-node operator, aka @, performs this function in JMESPath, e.g.

    $ echo '{"foo": true, "bar": 42}' | ~/.local/go/bin/jp @
    {
      "bar": 42,
      "foo": true
    }
    

    Thanks to jdevillard on https://gitter.im/jmespath/chat for the answer.