Crate jsonposition

Source
Expand description

Json Position is json library for finding the path to json at an index in the original string. Similar to extensions in most IDEs to get path to cursor position.

§Examples

use jsonposition::dot_path;
 
let json = r#"[9, {"name": "b", "fields": [null, null, 87, 4], "path": "file.txt"}]"#;
let position = json.find("87").unwrap();
 
let dotted = dot_path(json, position).expect("Invalid JSON");
assert_eq!(dotted, "$.1.fields.2");

Enums§

Index
Index or key into an array or object

Functions§

dot_path
Constructs the path of an index in a raw json string. Returns path in a human readable format usable by most JsonPath crates.
path
Constructs the path to an index in a raw json string.