Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser failed to understand syntax '$.anykey.~'. error message: Parse error at 1:12 near token ~ (~) #117

Open
madnanshah opened this issue Jan 12, 2023 · 2 comments

Comments

@madnanshah
Copy link

{ "mainkey": { "k1": {}, "k2": {} } }

From above, when I try to get keys with $.mainkey.*~
I expect ["k1","k2"] but I get following error

Parser failed to understand syntax '$.mainkey.'. error message:
Parse error at 1:12 near token ~ (
)

Result of pip install --upgrade jsonpath-ng

Requirement already satisfied: jsonpath-ng in /usr/local/lib/python3.10/dist-packages (1.5.3)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from jsonpath-ng) (1.16.0)
Requirement already satisfied: ply in /usr/local/lib/python3.10/dist-packages (from jsonpath-ng) (3.11)
Requirement already satisfied: decorator in /usr/local/lib/python3.10/dist-packages (from jsonpath-ng) (5.1.1)

@GalexyN
Copy link

GalexyN commented Mar 2, 2023

I think would could use something like this instead

obj = { "mainkey": { "k1": {}, "k2": {} } }
print(parse("$.mainkey").find(obj)[0].value.keys())

Does jsonpath-ng support tilde? I've only seen it used with =~ for regex filtering I believe

@AndreyMZ
Copy link

Duplicates #32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants