Serde_cursor: Extract nested field of JSON without making intermediate structs
⚓ Rust 📅 2026-03-20 👤 surdeus 👁️ 1Hi!
serde_cursor allows you to specify how to get the desired parts of any serde-compatible data format, such as JSON - using very lightweight syntax, and without loading the entire document into memory!
Extract version from Cargo.toml:
use serde_cursor::Cursor;
let data = r#"
[workspace.package]
version = "0.1"
"#;
let version: String = toml::from_str::<Cursor!(workspace.package.version)>(&data)?.0;
assert_eq!(version, "0.1");
Cursor!(workspace.package.version) is the magic juice - this macro expands to a type implementing Deserialize.
1 post - 1 participant
🏷️ Rust_feed