XmlJson.AwsApi (XmlJson v0.5.0) View Source

An AWS implementation of XML <=> JSON

Based on various conventions encountered in AWS XML-based APIs

Link to this section Summary

Link to this section Types

Specs

aws_api_options() ::
  %{list_element_names: [binary()], try_parse: boolean()}
  | [list_element_names: [binary()], try_parse: boolean()]

Link to this section Functions

Link to this function

deserialize(xml, opts \\ [])

View Source

Specs

deserialize(binary(), aws_api_options()) :: {:ok, map()} | {:error, term()}

Deserializes the given XML string.

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

Examples

iex> XmlJson.AwsApi.deserialize("<alice>bob</alice>")
{:ok, %{"alice" => "bob"}}

iex> XmlJson.AwsApi.deserialize("<alice><member>bob</member></alice>")
{:ok, %{"alice" => ["bob"]}}
Link to this function

deserialize!(xml, opts \\ [])

View Source

Specs

deserialize!(binary(), aws_api_options()) :: map()
Link to this function

serialize(object, opts \\ [])

View Source

Specs

serialize(map(), aws_api_options()) :: {:ok, binary()} | {:error, term()}

Serializes the given Map.

Returns an :ok tuple with a Map serialized to XML

Examples

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

iex> XmlJson.AwsApi.serialize(%{"alice" => ["bob", "jane"]})
{:ok, "<alice><member>bob</member><member>jane</member></alice>"}

iex> XmlJson.AwsApi.serialize(%{"alice" => [%{"name" => "bob"}, %{"name" => "jane"}]}, list_element_names: [""])
{:ok, "<alice><name>bob</name><name>jane</name></alice>"}
Link to this function

serialize!(map, opts \\ [])

View Source

Specs

serialize!(map(), aws_api_options()) :: binary()
Link to this function

serialize_as_params(object, opts \\ [])

View Source

Specs

serialize_as_params(map(), aws_api_options()) :: {:ok, map()} | {:error, term()}

Serializes the given Map as a set request parameters.

Returns an :ok tuple with a Map serialized to a flattened Map

Examples

iex> XmlJson.AwsApi.serialize_as_params(%{"alice" => "bob"})
{:ok, %{"alice" => "bob"}}

iex> XmlJson.AwsApi.serialize_as_params(%{"alice" => ["bob", "jane"]})
{:ok, %{"alice.member.1" => "bob", "alice.member.2" => "jane"}}

iex> XmlJson.AwsApi.serialize_as_params(%{"alice" => ["bob", "jane"]}, list_element_names: [""])
{:ok, %{"alice.1" => "bob", "alice.2" => "jane"}}
Link to this function

serialize_as_params!(map, opts \\ [])

View Source

Specs

serialize_as_params!(map(), aws_api_options()) :: map()