8000 Negative array slicing? by gregglind · Pull Request #6 · kennknowles/python-jsonpath-rw · GitHub
[go: up one dir, main page]

Skip to content

Negative array slicing? #6

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

Merged
merged 1 commit into from
Jul 23, 2013

Conversation

gregglind
Copy link
Contributor

In particular, $[-1] (which is very pythonic, but maybe not very JSONic?) would be helpful.

@kennknowles
Copy link
Owner

This is a great idea. Have you tried it?

I have never tried it, but it is intended to work:

I can't switch to this right now, but I'll try it out and make a test case later. It would be great if you dropped a note here as well.

@kennknowles
Copy link
Owner

Actually it appears that you also are requesting negative indices, for which the same two points apply.

@gregglind
Copy link
Contributor Author

It is negative indexing... I think the problem is in the lexer:

https://github.com/kennknowles/python-jsonpath-rw/blob/master/jsonpath_rw/lexer.py#L64 which is \d+.

I will poke at it a bit more :)

>> parse($[-1])
AttributeError: 'LexToken' object has no attribute 'latest_newline'

@kennknowles
Copy link
Owner

Ah yes. Adding negatives should not cause any difficulties with parsing.

@kennknowles
Copy link
Owner

Great, and thanks for the tests.

kennknowles added a commit that referenced this pull request Jul 23, 2013
@kennknowles kennknowles merged commit 97c6823 into kennknowles:master Jul 23, 2013
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

Successfully merging this pull request may close these issues.

2 participants
0