Open slandelle opened 2 years ago
JMESPath used to support strings using this syntax: `this was a string`
.
However, JEP-12 made this syntax obsolete.
Now, the grammar is much clearer. You can only have:
quoted-string
: simple JSON strings easy to input using simple quotes. e.g 'hello world!'
.raw-string
literals : JSON values typed verbatim (except, backtick must be escaped). e.g `"{}`"
would be an empty JSON object. Please, note that a JSON string has surrounding double quotes, and thus mus be input like so `"this is a string"`
.Your question is raised in the context of numeric literals. JMESPath does not support JSON numbers in its grammar. So those must be input using raw-string
literals. Thus:
fruits[? details.size >= `500` ]
filters all fruits whose size is greater than number 500
. fruits[? details.size >= '500' ]
filters all fruits whose size is greater than string "500"
. Probably not what you want.Comparisons between numbers and strings is currently undefined in the grammar as ordering operators are only valid between two numbers. However, popular implementations do make some attempt to cast the string to a number before performing the comparison, so it mostly works even though it is not standards-compliant.
Hi,
According to the JMESPath specification:
This implementation doesn't abide to the specification and allows literals to be also wrapped with single quotes.
On the online evaluator on https://jmespath.org/ (using this implementation), both following expressions work. Only the former should. The latter should return an empty array.
For the record, the Java implementation works as expected.
Regards