json-pluck 0.1.0

Pluck a single value out of a serde_json::Value by dotted path or simple JSONPath. Lossy, forgiving, intended for LLM-emitted JSON.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 3 items with examples
  • Size
  • Source code size: 23.71 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 290.65 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • MukundaKatta/json-pluck
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MukundaKatta

json-pluck

crates.io

Pluck a single value out of a serde_json::Value by dotted path or a tiny subset of JSONPath. Forgiving, built for LLM-emitted JSON where the answer is buried under unpredictable wrappers.

use json_pluck::pluck;
use serde_json::json;

let v = json!({ "result": { "items": [{ "value": 1 }, { "value": 42 }] } });
assert_eq!(pluck(&v, "result.items[1].value"), Some(&json!(42)));
assert_eq!(pluck(&v, "result.items[-1].value"), Some(&json!(42)));
assert_eq!(pluck(&v, "**.value"), Some(&json!(1)));

**.field BFS-searches the whole tree for the first match. MIT or Apache-2.0.