Expand description

JsonML crate

JsonML deserialization and serialization

Deserialization example:

use jsonml::{Element, AttributeValue, Tag};

let element: Element =
    serde_json::from_str(r#"[ "li", { "style": "color:red" }, "First Item" ]"#)
        .expect("deserialize element tag");
assert_eq!(
    element,
    Element::Tag(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 jsonml::{Element, AttributeValue, Tag};

let element = Element::Tag(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:

Structs

WARNING: The fields will be hidden in the future for validation.

Enums