Skip to content

semlabs/json_to_xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>