| Crates.io | serde_sono |
| lib.rs | serde_sono |
| version | 0.5.0 |
| created_at | 2025-05-10 10:31:05.159114+00 |
| updated_at | 2025-05-29 14:05:34.578076+00 |
| description | Sono data format de-/serialization implementations for serde |
| homepage | |
| repository | https://github.com/xitep/serde-sono.git |
| max_upload_size | |
| id | 1668283 |
| size | 179,980 |
A serde de-/serializer for the Sono data format.
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct Hobby(String);
#[derive(Deserialize, Debug)]
struct Person {
name: String,
age: u32,
hobby: Hobby,
#[serde(default)]
friends: Vec<Person>,
}
fn main() {
let input = r#"
Person {
name: "katie",
age: 10,
hobby: "reading",
friends: [
{ name: "tom", age: 33, hobby: "writing" },
Person("bea", 9, Hobby("transpiling"), []),
Person { name: "josh", hobby: "dreaming", age: 12 },
]
}
"#;
match serde_sono::from_str::<Person>(input) {
Err(e) => println!("syntax error: {e:#}"),
Ok(value) => println!("{value:#?}"),
}
}
See https://github.com/xitep/sono
serde_sono::Valuevalue: enabled by default; guards the serde_sono::Value type
lossless-serialize-value-leaking: Implements serde::Serialize
for serde_sono::Value producing a lossless presentation of the
serialized values at the cost of leaking memory for object names and
property keys to support serializes which do retain references to
these.
The feature is disabled by default and results in objects being serialized as lists and/or maps of their properties.
This feature is an alternative to lossless-serialize-value-unsafe.
lossless-serialize-value-unsafe: Implements serde::Serialize for
serde_sono::Value producing a lossless presentation of the
serialized values by assuming that the used serializer does not
retain references to the handed object and property names. (The
serializer provided by serde_sono, for example, does not.)
The feature is disabled by default and results in objects being serialized as lists and/or maps of their properties.
This feature is an alternative to lossless-serialize-value-leaking.