Skip to content

Commit

Permalink
Merge pull request #18 from cjschneider2/master
Browse files Browse the repository at this point in the history
add `xml_str_to_json` function
  • Loading branch information
AlecTroemel authored Jan 27, 2022
2 parents 5c884d5 + a95a0d8 commit 74ca743
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,12 @@ fn xml_to_map(e: &Element, config: &Config) -> Value {

/// Converts the given XML string into `serde::Value` using settings from `Config` struct.
pub fn xml_string_to_json(xml: String, config: &Config) -> Result<Value, Error> {
let root = Element::from_str(xml.as_str())?;
xml_str_to_json(xml.as_str(), config)
}

/// Converts the given XML string into `serde::Value` using settings from `Config` struct.
pub fn xml_str_to_json(xml: &str, config: &Config) -> Result<Value, Error> {
let root = Element::from_str(xml)?;
Ok(xml_to_map(&root, config))
}

Expand Down

0 comments on commit 74ca743

Please sign in to comment.