JsonToXml
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"}]
endUsage
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:
XML:{ "": "content }<root> <>content</> </root>