h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
603 stars 87 forks source link

Unexpected character '~' #32

Open gramscih opened 4 years ago

gramscih commented 4 years ago

When I am trying to obtain the keys from this json json = { "ens33": { "flags": "4163<UP,BROADCAST,RUNNING,MULTICAST>", "mtu": "1500", "inet": "10.2.10.36", "netmask": "255.255.255.0", "broadcast": "10.2.10.255" }, "lo": { "flags": "73<UP,LOOPBACK,RUNNING>", "mtu": "65536", "inet": "127.0.0.1", "netmask": "255.0.0.0", "inet6": "::1", "prefixlen": "128", } }

with the following code

keys = parse("$.*~").find(json) Expected result ["ens33", "lo"]

But I have this error jsonpath_ng.lexer.JsonPathLexerError: Error on line 1, col 3: Unexpected character: ~

some workaround to obtain the keys from json?

Thanks in advance

h2non commented 4 years ago

This should be fixed in v1.5.1.

xPi2 commented 4 years ago

Hi! Any news on this?

h2non commented 4 years ago

Can you upgrade to latest version from PyPi? pip install --upgrade jsonpath-ng

thanh-dinh commented 4 years ago

@h2non still not working, what was the merged of fix please? raise Exception('Parse error at %s:%s near token %s (%s)' % (t.lineno, t.col, t.value, t.type)) Exception: Parse error at 1:3 near token ~ (~)

from jsonpath_ng.ext import parse

json_path_expression = parse("$.*~") matches = json_path_expression.find(json) for match in matches: print(match.value)

thanh-dinh commented 4 years ago

@GramsciH @XPi2 any solutions please?

sadilet commented 2 years ago

@h2non @gramscih sorry for bothering, is there any update? maybe is there custom patch?