No description
Find a file
2021-11-25 19:45:47 +01:00
src Update json2xml.nim 2021-03-16 16:29:15 +01:00
tests json to xml 2021-03-13 18:17:01 +01:00
json2xml.nimble json to xml 2021-03-13 18:17:01 +01:00
LICENSE Initial commit 2021-03-13 18:13:58 +01:00
README.md Update README.md 2021-11-25 19:45:47 +01:00

json2xml '[_]'

  • convert json to xml : JsonNode json to xmltree type XmlNode

Install

  • nimble install json2xml

Usage

  • example
import json , xmltree , json2xml 
var js = %* {
    "Name": "voldemort",
    "Designation": "PHP Developer",
    "Salary": 98000,
    "Age": 27,
    "Projects": [
        {
            "Topic": "Smart Ambulance",
            "Category": "Android Application",
            "Months": 2
        },
        {
            "Topic": "AST",
            "Category": "Embedded System",
            "Months": 1
        },
        {
            "Topic": "Plant Nursery",
            "Category": "Website",
            "Months": 3
        }
    ]
}
var xml_from_json : XmlNode = json2xml(js)
echo xml_from_json 
  • output
<json type="object">
  <json type="key" name="Name"><json type="string">voldemort</json></json>
  <json type="key" name="Designation"><json type="string">PHP Developer</json></json>
  <json type="key" name="Salary"><json type="int">98000</json></json>
  <json type="key" name="Age"><json type="int">27</json></json>
  <json type="key" name="Projects"><json type="list">
      <json type="index" value="0"><json type="object">
          <json type="key" name="Topic"><json type="string">Smart Ambulance</json></json>
          <json type="key" name="Category"><json type="string">Android Application</json></json>
          <json type="key" name="Months"><json type="int">2</json></json>
        </json></json>
      <json type="index" value="1"><json type="object">
          <json type="key" name="Topic"><json type="string">AST</json></json>
          <json type="key" name="Category"><json type="string">Embedded System</json></json>
          <json type="key" name="Months"><json type="int">1</json></json>
        </json></json>
      <json type="index" value="2"><json type="object">
          <json type="key" name="Topic"><json type="string">Plant Nursery</json></json>
          <json type="key" name="Category"><json type="string">Website</json></json>
          <json type="key" name="Months"><json type="int">3</json></json>
        </json></json>
    </json></json>
</json>