serde_zipson is serde-compatible Rust implementation of zipson compression format.
serde_zipson playground is available on Github Pages
use indexmap::IndexMap;
use serde_zipson::ser::to_string;
use serde_zipson::value::{Number, Value};
fn main() {
let string = to_string(
&Value::Object(
IndexMap::from([
("x".to_string(), Value::Number(Number::Int(1))),
("y".to_string(), Value::Number(Number::Int(2)))
])
),
true, // full_precision_floats
true, // detect_utc_timestamps
).unwrap();
assert_eq!(string, "{´x´Ê´y´Ë}");
}use indexmap::IndexMap;
use serde_zipson::de::from_str;
use serde_zipson::value::{Number, Value};
fn main() {
let value = from_str::<Value>("{´x´Ê´y´Ë}").unwrap();
assert_eq!(
value,
Value::Object(
IndexMap::from([
("x".to_string(), Value::Number(Number::Int(1))),
("y".to_string(), Value::Number(Number::Int(2)))
])
)
);
}use serde_zipson::de::from_str;
use serde_zipson::value::Value;
fn main() {
let zipson_value = from_str::<Value>("{´x´Ê´y´Ë}").unwrap();
let json_value = serde_json::to_value(zipson_value).unwrap();
let json_string = json_value.to_string();
assert_eq!(json_string, "{\"x\":1,\"y\":2}");
}use serde_json::from_str;
use serde_zipson::value::Value;
use serde_zipson::ser::to_string;
fn main() {
let json_value = from_str::<serde_json::Value>("{\"x\":1,\"y\":2}").unwrap();
let zipson_value = serde_json::from_value::<Value>(json_value).unwrap();
let zipson_string = to_string(&zipson_value, true, true).unwrap();
assert_eq!(zipson_string, "{´x´Ê´y´Ë}");
}serialize_struct/deserialize_structare not implemented yet, so serdederivedoesn't work for structsserialize_enum/deserialize_enumare not implemented yet, so serdederivedoesn't work for enumsserde_zipsonpanics on integer overflowserde_zipsonobject template feature not working yet, so[{"key":"value1"},{"key":"value2"}]ends up in|{¨key¨¨value1¨}{ß0¨value2¨}÷instead of|¦¨key¨‡¨value1¨¨value2¨—÷
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.