qntfy / kazaam

Arbitrary transformations of JSON in Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request - Reverse-indexing of arrays

jnanasagar opened this issue Β· comments

First of all, I would like to thank everyone for contributing to this project, it's really great and works very well. πŸ‘

Feature :
Currently, we can access the first element of an array of JSON objects with indexing.
The first element of an array: array[0]
Nth element of an array: array[n]
Can we please add a feature to do reverse indexing of the array? This would be very useful when one would be aware of the length of an array.
Or access the last element of an array with index -1.

I would like to take up this task if it can be accepted.

Hi @jnanasagar, thank you for this! We would support this functionality but it is not in our current scope, so if you want to take it on please do!

Currently we retrieve elements from array with the underlying qntfy/jsonparser as seen here so you would want to add this functionality there and then make sure kazaam could pick up the new version (I can take care of that part for you). I believe the underlying code you'd want to update is here and we would also need a few new test cases to cover this in jsonparser. If you want to submit the MR to qntfy/jsonparser and tag me I'm happy to review.

Thank you!!