8 releases (4 breaking)
Uses new Rust 2024
| 0.5.1 | May 10, 2026 |
|---|---|
| 0.5.0 | Mar 27, 2026 |
| 0.4.2 | Feb 5, 2023 |
| 0.4.1 | Sep 21, 2022 |
| 0.1.0 | Aug 27, 2022 |
#755 in Encoding
19KB
447 lines
JsonML crate
JsonML deserialization and serialization.
- GitHub (former repository was at GitLab)
- documentation
Deserialization example:
# use std::collections::HashMap;
use jsonml::{Element, AttributeValue};
let element: Element =
serde_json::from_str(r#"[ "li", { "style": "color:red" }, "First Item" ]"#)
.expect("deserialize element tag");
assert_eq!(
element,
Element::Tag {
name: "li".to_string(),
attributes: HashMap::from([(
"style".to_string(),
AttributeValue::String("color:red".to_string())
)]),
element_list: vec![Element::String("First Item".to_string())]
}
);
Serialization example:
# use std::collections::HashMap;
use jsonml::{Element, AttributeValue};
let element = Element::Tag {
name: "li".to_string(),
attributes: HashMap::from([(
"style".to_string(),
AttributeValue::String("color:red".to_string()))]
),
element_list: vec![Element::String("First Item".to_string())]
};
assert_eq!(
serde_json::to_string(&element).expect("serialize element tag"),
r#"["li",{"style":"color:red"},"First Item"]"#
);
License
Licensed under either of the following at your option:
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~0.4–1MB
~21K SLoC