PaesslerAG / jsonpath

BSD 3-Clause "New" or "Revised" License
172 stars 37 forks source link

Add support for using Gval's variable selectors #18

Closed impl closed 4 years ago

impl commented 4 years ago

Hello!

Thank you for writing this library! The extensibility is very impressive. We're looking into using it in one of our projects and it would be helpful to be able to do some data sanitization before a key is used. I found VariableSelector in Gval, but this library didn't support it, so I attempted to add it here.

I think I addressed most every case where someone would want to inject custom behavior, but I'm more than happy to make any revisions or suggestions you might like.

I also exposed parseRootPath as a public function because we want to support kubectl-style JSONPath "templates", which look like { .foo.bar } instead of $.foo.bar (but are otherwise identical).

Thanks again!

impl commented 4 years ago

It turns out that this is substantially more complex than I thought. I finally got it working in a way that seems robust, but in the process I rewrote a lot of this library, probably more than is reasonable to put into a pull request. You can see the scope of the changes in the most recent commit linked here. Of course, if you'd like to chat about including it feel free to shoot me an email and we can go from there!