jmespath / jmespath.js

Javascript implementation of JMESPath, a query language for JSON
http://jmespath.org
Other
776 stars 95 forks source link

Dash should not be treated as a valid character in unquoted identifiers #80

Closed oliverrahner closed 2 years ago

oliverrahner commented 2 years ago

According to the spec (and https://github.com/jmespath/jmespath.rb/issues/12),

- is not valid in unquoted identifiers as it is used for negative numbers

But the simulator on the jmespath front page does not complain.

I wasn't familiar with jmespath and tried to build a valid expression, then carried it to the application I wanted to use it with and wondered for some hours why it didn't do what I wanted.

Example:

Expression: contains(resource_access.monitoring-application.roles[*], 'admin') && 'I am ze admin!'

Document:

{
  "resource_access": {
    "monitoring-application": {
       "roles": [
          "admin"
       ]
    }
  }
}

The above should not be valid, but returns "I am ze admin!". The go implementation errors out with "SyntaxError: Invalid token: tNumber"

oliverrahner commented 2 years ago

Just saw that this is already addressed in #67