You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Numeric literals can only wrapped with backticks, not single quotes #85
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.
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.
Activity
springcomp commentedon Aug 1, 2022
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-stringliterals : 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-stringliterals. Thus:fruits[? details.size >= `500` ]filters all fruits whose size is greater than number500.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.