| Crates.io | spath |
| lib.rs | spath |
| version | 0.3.1 |
| created_at | 2025-01-05 16:51:52.993007+00 |
| updated_at | 2025-02-23 10:43:42.185171+00 |
| description | SPath is query expressions for semi-structured data. You can use it as a drop-in replacement for JSONPath, but also for other semi-structured data formats like TOML or user-defined variants. |
| homepage | https://github.com/cratesland/spath |
| repository | https://github.com/cratesland/spath |
| max_upload_size | |
| id | 1504929 |
| size | 184,124 |
You can use it as a drop-in replacement for JSONPath, but also for other semi-structured data formats like TOML or user-defined variants.
Here is a quick example that shows how to use the spath crate to query JSONPath alike expression over JSON data:
use serde_json::json;
use spath::SPath;
#[test]
fn main() {
let data = json!({
"name": "John Doe",
"age": 43,
"phones": [
"+44 1234567",
"+44 2345678"
]
});
let registry = spath::json::BuiltinFunctionRegistry::default();
let spath = SPath::parse_with_registry("$.phones[1]", registry).unwrap();
let result = spath.query(&data);
let result = result.exactly_one().unwrap();
assert_eq!(result, &json!("+44 2345678"));
}
spath is on crates.io and can be used by adding spath to your dependencies in your project's Cargo.toml. Or more simply, just run cargo add spath.
This project is licensed under Apache License, Version 2.0.
From 0.3.0, this crate is reimplemented as a fork of serde_json_path, with modifications:
impl Ord for PathElement