besok / jsonpath-rust

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

Can we expose some methods and types? #73

Closed paomian closed 1 month ago

paomian commented 1 month ago

Can we expose methods and types so that other libraries or applications can rely on such libraries to implement json path functionality for their own json like types?

I want to impl Path trait for my own json like Enum type. So I'm relying on such libraries in my application and want to implement json path functionality for my json like types, but there are some methods and types that I can't call, such as flat_map_slice JsonPathIndex and I'd have to fork a copy of the code to expose these methods and types. Has it been considered to provide trait and utility methods for other libraries or applications to use?

besok commented 1 month ago

That sounds good, we need to implement it

paomian commented 1 month ago

I submitted a https://github.com/besok/jsonpath-rust/pull/74 to prove my idea. It is possible to define a trait that, once implemented, will allow you to use the functionality that the json path brings. So far it compiles and all tests pass.