# serde_sono
A [serde](https://serde.rs/) de-/serializer for the [Sono data format](https://github.com/xitep/sono).
# Example
```rust
use serde::Deserialize;
#[derive(Deserialize, Debug)]
#[allow(dead_code)]
struct Hobby(String);
#[derive(Deserialize, Debug)]
#[allow(dead_code)]
struct Person {
name: String,
age: u32,
hobby: Hobby,
#[serde(default)]
friends: Vec<Person>,
}
fn main() {
let s = r#"
Person {
name: "pete",
age: 10,
hobby: "reading",
friends: [
{ name: "tom", age: 33, hobby: "writing" },
Person("mike", 9, Hobby("transpiling"), []),
Person("josh", 12, "dreaming"),
]
}
"#;
match serde_sono::from_str::<Person>(s) {
Err(e) => println!("syntax error: {e:#}"),
Ok(value) => println!("{value:#?}"),
}
}
```
# SONO language
See https://github.com/xitep/sono
# TODOs
- [ ] Pretty formatting when serializing
- [X] Generic data model `serde_sono::Value`
- [X] Efficient value skipping / ignoring
- [ ] Documentation
- [ ] Measure and tweak performance
# Features
- *value*: enabled by default; guards the `serde_sono::Value` type
- *fast-ignore*: enabled by default; provides a fast implementation of
`Deserializer::deserialize_ignored_any` at the cost of a less strict
error detection. In particular, the "ignoring" parser _may_ be more
forgiving and accept certain syntacial errors as long as determining
a "value" to skip from the input stream is possible without
ambiguity.
- *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`.