Skip to content

Latest commit

 

History

History
48 lines (38 loc) · 1.13 KB

README.md

File metadata and controls

48 lines (38 loc) · 1.13 KB

JsonToXml

Build Status Hex.pm Hex.pm

Convert JSON strings to XML.

Installation

The package can be installed by adding json_to_xml to your list of dependencies in mix.exs:

def deps do
  [{:json_to_xml, "~> 0.4.0"}]
end

Usage

After adding the dependency you can use the converter like this:

JsonToXml.convert!(~s({ "name": "John" }))
#=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n\t<name>John</name>\n</root>"

To convert files use convertFile:

JsonToXml.convertFile!("/path/to/file")

Documentation

The docs can be found at https://hexdocs.pm/json_to_xml.

Known issues

  • JSON with empty keys is not supported and leads to an empty XML tag: JSON:
{
    "": "content
}

XML:

<root>
    <>content</>
</root>