XmlJson.BadgerFish (XmlJson v0.5.0) View Source
The BadgerFish implementation of XML <=> JSON
Link to this section Summary
Link to this section Types
Specs
Link to this section Functions
Specs
deserialize(binary(), badgerfish_options()) :: {:ok, map()} | {:error, term()}
Deserializes the given XML string.
Returns an :ok
tuple with the XML deserialized to a Map
Examples
iex> XmlJson.BadgerFish.deserialize("<alice>bob</alice>")
{:ok, %{"alice" => %{"$" => "bob"}}}
iex> XmlJson.BadgerFish.deserialize("<alice xmlns=\"https://default.example.com\">bob</alice>", exclude_namespaces: true)
{:ok, %{"alice" => %{"$" => "bob"}}}
Specs
deserialize!(binary(), badgerfish_options()) :: map()
Specs
serialize(map(), badgerfish_options()) :: {:ok, binary()} | {:error, term()}
Serializes the given Map.
Returns an :ok
tuple with a Map serialized to XML
Examples
iex> XmlJson.BadgerFish.serialize(%{"alice" => %{"$" => "bob"}})
{:ok, "<alice>bob</alice>"}
iex> XmlJson.BadgerFish.serialize(%{"alice" => %{"$" => "bob", "@xmlns" => %{"$" => "https://default.example.com"}}}, exclude_namespaces: true)
{:ok, "<alice>bob</alice>"}
Specs
serialize!(map(), badgerfish_options()) :: binary()