jmespath / jmespath.py

JMESPath is a query language for JSON.
http://jmespath.org
MIT License
2.19k stars 181 forks source link

Raw literal string does not handle escaped single quote #85

Closed jamesls closed 9 years ago

jamesls commented 9 years ago

When using a raw string literal ('foobar'), escaping the single quote results in the \ char still present in the output. For example:

import jmespath
print(jmespath.compile(r"'foo\'bar'"))
# prints: {'type': 'literal', 'children': [], 'value': "foo\\'bar"}

The expected result should be the single quote without the escaped char:

{'type': 'literal', 'children': [], 'value': "foo'bar"}

Consider the case when using double quotes or literals. Both of these handle escaping the delimiting character:

print(jmespath.compile(r'"foo\"bar"'))
# prints: {'type': 'field', 'children': [], 'value': u'foo"bar'}

print(jmespath.compile(r'`foo\`bar`'))
{'type': 'literal', 'children': [], 'value': u'foo`bar'}