simd-json icon indicating copy to clipboard operation
simd-json copied to clipboard

"pluck" or "nested get" functionality?

Open rrichardson opened this issue 2 years ago • 2 comments

I have a need for very high speed access to fetch a couple fields within a deeply nested JSON blob, I would prefer not to have to deser the entire blob for only a couple of fields.

Is there a way to accomplish something like:


let blob: &str = get_deep_json_string(); 
let total: i64 = simd_json::pluck("foo.bar.baz.total", blob)?; 
let mystr: &str = simd_json::pluck("foo.wat.huh.summary", blob)?; 

rrichardson avatar Apr 12 '22 15:04 rrichardson

After writing that, I guess this would equate to adding json-path functionality, or similar, which sounds far less trivial than I originally thought. The existing json-path libs in Rust do require deserialization into a serde-json Value first, which certainly doesn't offer the perf benefits that I'm after.

rrichardson avatar Apr 12 '22 15:04 rrichardson

One option that might work well is delserialize to a tape (that's fairly cheap) and then get the value from the tame?

Licenser avatar Apr 12 '22 16:04 Licenser

closing as a duplicate of #82 since no objection was made to using the tape

Licenser avatar Oct 09 '23 12:10 Licenser