2 releases
Uses old Rust 2015
0.1.1 | Jul 16, 2018 |
---|---|
0.1.0 | Jul 13, 2018 |
#53 in #serializer-deserializer
67KB
2K
SLoC
sion-rs
SION serializer/deserializer implementation in Rust.
How to use
Add the following to your Cargo.toml
[dependencies]
serde = "1.0"
serde_derive = "1.0"
sion-rs = "0.1"
Then you can use serde's Serialize
/Deserialize
to deal with SION data.
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate sion_rs;
use sion_rs::{to_string, from_str};
fn main() {
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
struct Person {
name: String,
age: u32,
}
let person = Person {
name: "dankogai".into(),
age: 48,
};
let expected = r#"["name":"dankogai","age":48]"#;
assert_eq!(to_string(&person).unwrap(), expected);
let deserialized = from_str::<Person>(expected).unwrap();
assert_eq!(deserialized, person);
}
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Future work
- handle
.Date
correctly (nowsion-rs
treats any.Date
as a single float, collapsing the structure) - benchmark and optimize
- support other input/output formats than
str
- write document
Dependencies
~1.1–1.8MB
~37K SLoC