besok / jsonpath-rust

Support for json-path in Rust
https://crates.io/crates/jsonpath-rust
MIT License
99 stars 26 forks source link

POC API that avoids clone for consideration. #44

Closed BrynCooke closed 1 year ago

BrynCooke commented 1 year ago

Hi!

I came across this library a while back when I was looking at different jsonpath libraries and it looks nice. The only issue seemed to be that the JsonPathFinder API seemed to require cloning to happen, which was a showstopper for my use case. Recently I had cause to look again as the other major jsonpath library for Rust looks abandoned and has bugs.

It looks like the underlying query implementation for jsonpath-rustsupports query without having to clone the input data, however the use of JsonPathFinder forces this to happen.

This PR is a POC API for querying without cloning that introduces a new enum JsonPtr for holding values. The reason this has to exist is that deref on JsonPathValue is not possible without a panic for NoValue.

It'd be great if this approach could be considered for this project.

besok commented 1 year ago

Hi. Thanks for the PR. That is great, that you use the library.

Sure, the change seems to be useful. let's bring it in

BrynCooke commented 1 year ago

Awesome. I've pushed some minor polish. Let me know if there's anything else you'd like to see. Of course if you have changes in mind that you'd like to make yourself then I'm also happy for you take it over the line.

besok commented 1 year ago

Great. Thanks. That is a really helpful change.