Convert JSON strings to XML.
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
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")
The docs can be found at https://hexdocs.pm/json_to_xml.
- JSON with empty keys is not supported and leads to an empty XML tag: JSON:
{
"": "content
}
XML:
<root>
<>content</>
</root>