XmlJson.Parker (XmlJson v0.1.1) View Source

The Parker implementation of XML <=> JSON

https://developer.mozilla.org/en-US/docs/Archive/JXON#The_Parker_Convention

Link to this section Summary

Functions

Deserializes the given XML string. Takes an option (preserve_root, defaults to false) for hoisting the root element or not

Serializes the given Map. Takes an option (preserve_root, defaults to "root") for what property to hoist or inject as the root element

Link to this section Functions

Link to this function

deserialize(xml, opts \\ [])

View Source

Deserializes the given XML string. Takes an option (preserve_root, defaults to false) for hoisting the root element or not

Returns an :ok tuple with the XML deserialized to a Map

Examples

iex> XmlJson.Parker.deserialize("<alice>bob</alice>", preserve_root: true)
{:ok, %{"alice" => "bob"}}
Link to this function

serialize(value, opts \\ [])

View Source

Serializes the given Map. Takes an option (preserve_root, defaults to "root") for what property to hoist or inject as the root element

Returns an :ok tuple with the Map serialized to XML

Examples

iex> XmlJson.Parker.serialize(%{"alice" => "bob"}, preserve_root: "alice")
{:ok, "<alice>bob</alice>"}