Open Adam-Vandervorst opened 4 months ago
Yes, pointer!
has limitations when it comes to retrieving multiple keys from a large JSON.
If we want to perform quick and flexible searches on large JSON data as above, it is advisable to support the JSONPath RFC. While it is included in the roadmap, it may not be completed shortly.
There is an existing high-performance JSONPath library available at https://github.com/rsonquery/rsonpath that can be used for your purpose.
Is your feature request related to a problem? Please describe.
If you want to project out a simple structure out of a large JSON you have two options: a) Formalize the large JSON scheme, parse that, and post-process it b) Get the parts you need with using paths
However, a) is expensive for the programmer, and b) is quite limited and computationally expensive if you want to get around that
Describe the solution you'd like
let vs = sonic_rs::get(line, sonic_rs::pointer!["aliases", "en", Index, "value"])
and
let o = sonic_rs::get(line, sonic_rs::pointer!["aliases", Key, 0, "value"])
Describe alternatives you've considered
and
Additional context
Think about it as using a well-typed Glob for your JSON. Notably, the workaround gets quadratically worse when you have more placeholders in your path.