h2non / jsonpath-ng

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

Added comma for index + step in slice #102

Open elrandira opened 2 years ago

elrandira commented 2 years ago

This is my proposition to add comma in index such as in $..books[1,2] and step in slice such as in $..books[::-1] or $..books[0:3:2]

for the comma in index, the code is similar to handling of comma in fields. https://github.com/h2non/jsonpath-ng/issues/28

For step in slice, all the code was already there, just needed to implement the rule... ¯_(ツ)_/¯

All tests passed + new ones

michaelmior commented 11 months ago

@elrandira Sorry for the very long delay. If you're still interested in having this merged and you're able to update the PR, let me know!

elrandira commented 11 months ago

sure, I'll try in the next days. I am going to need to setup the environment again for this.

kurtmckee commented 10 months ago

This will conflict with a documented JSONPath syntax for selecting multiple indexes simultaneously:

image

https://goessner.net/articles/JsonPath/index.html#e3

This PR should be closed to avoid introducing conflicting syntax.

kurtmckee commented 10 months ago

I think I misread this; my interpretation was that this was offering commas as an alternative to colons in slice syntax, but now that I've read the code that doesn't appear to be what's happening here.

I recommend merging #145 first, which heavily parametrizes the test suite. It will make it easier to integrate the tests introduced here.