Open cvancar opened 4 years ago
I ran into a similar issue; wrapping the search terms in single quotes worked for me:
from jsonpath_ng import jsonpath
from jsonpath_ng.ext import parse
data = [{"test" : "hello"}, {"test" : "a/b"}]
print(parse("$[?(@.test=hello)]").find(data)[0].value)
# {'test': 'hello'}
print(parse("$[?(@.test='a/b')]").find(data)[0].value)
# {'test': 'a/b'}
data2 = {"a" : "b", "c/d" : "e"}
print(parse("$.a").find(data2)[0].value)
# b
print(parse("$.'c/d'").find(data2)[0].value)
# e
It would be great if there was an escape
function in the library that would properly escape any special characters so they could be used as a component of a path.
Hello,
I am getting the exception while execution following example:
import json import jsonpath_rw_ext text = '{"name/subname": "value"}' json = json.loads(text) matches = jsonpath_rw_ext.match("name/subname", json)
How to escape the character '/', please?
Thank you. Petr