{"_id":"@7ft/another-json-xml","name":"@7ft/another-json-xml","dist-tags":{"latest":"2.0.8"},"versions":{"2.0.8":{"name":"@7ft/another-json-xml","version":"2.0.8","description":"Another json to xml convertor.","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/nikolai-shilin/another-json-xml.git"},"keywords":["json","xml","convertor","convertor","json2xml","transform","json-to-xml","transformer","translate","translater","translator","formatter"],"author":{"name":"Nikolai Shilin"},"license":"ISC","publishConfig":{"access":"public"},"bugs":{"url":"https://github.com/nikolai-shilin/another-json-xml/issues"},"homepage":"https://github.com/nikolai-shilin/another-json-xml#readme","gitHead":"c0d081728d61310db9567540cd36b277e24d1b40","_id":"@7ft/another-json-xml@2.0.8","_nodeVersion":"18.12.0","_npmVersion":"9.6.1","dist":{"integrity":"sha512-/5lhX2CuPFxxnx5w4JHFh+xTrvnYHRxx85yjzFJgacBIgX4Sp8U37u+ndo3kyp/jkWjVeVC+KBggRu/R2tHvbQ==","shasum":"1b5e4cd5c729e46e498b576e4615d30418726421","tarball":"https://registry.npmjs.org/@7ft/another-json-xml/-/another-json-xml-2.0.8.tgz","fileCount":4,"unpackedSize":5317,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICpHS1lPAGZVMsUiOHjP7qXuq+3nKsVCOskuegh/eypUAiEAwIR9hOi0nrhBKnig3oc94IBWb+Wr20Z0NzpCRx50aLg="}]},"_npmUser":{"name":"fullcrimp","email":"fullcrimpdev@gmail.com"},"directories":{},"maintainers":[{"name":"fullcrimp","email":"fullcrimpdev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/another-json-xml_2.0.8_1713249628676_0.7534082008873955"},"_hasShrinkwrap":false}},"time":{"created":"2024-04-16T06:40:28.529Z","2.0.8":"2024-04-16T06:40:28.809Z","modified":"2024-04-16T06:40:29.075Z"},"maintainers":[{"name":"fullcrimp","email":"fullcrimpdev@gmail.com"}],"description":"Another json to xml convertor.","homepage":"https://github.com/nikolai-shilin/another-json-xml#readme","keywords":["json","xml","convertor","convertor","json2xml","transform","json-to-xml","transformer","translate","translater","translator","formatter"],"repository":{"type":"git","url":"git+https://github.com/nikolai-shilin/another-json-xml.git"},"author":{"name":"Nikolai Shilin"},"bugs":{"url":"https://github.com/nikolai-shilin/another-json-xml/issues"},"license":"ISC","readme":"# Another json/xml converter\n\nConverts JSON or object to XML. In case of array, it will create a new element for each item named as parent element without the last symbol e.g. `cars` -> `car` items  or with a name defined in a config parameter `singulars`: `people: 'person'`.\n\n## How to install\n```\nnpm install another-json-xml --save\n```\n\n# How to use\n```\nconst { json2xml } = require('another-json-xml');\n\nconst json = {\n  \"name\": \"John\",\n  \"age\": 30,\n  \"cars\": [\n    {\n      \"name\": \"Ford\"\n    }, {\n      \"name\": \"BMW\"\n    }, {\n      \"name\": \"Fiat\"\n    }\n  ]\n}\nconst xml = json2xml(json);\n```\n\nresult\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root>\n\t<name>John</name>\n\t<age>30</age>\n\t<cars>\n\t\t<car>\n\t\t\t<name>Ford</name>\n\t\t</car>\n\t\t<car>\n\t\t\t<name>BMW</name>\n\t\t</car>\n\t\t<car>\n\t\t\t<name>Fiat</name>\n\t\t</car>\n\t</cars>\n</root>\n```\n\n# Config (optional)\n\nYou can pass config object as a second parameter to `json2xml` function e.g.\n```\nconst xml = json2xml(json, config);\n```\n\nOr wrap it in a function for a shared config settings and use as a function e.g.\n```\nconst { getConfiguredJson2Xml } = require('another-json-xml');\n\nconst json2xml = getConfiguredJson2Xml({\n  root: 'root',\n  indent: '\\t',\n  exclude: [],\n  minify: false,\n  singulars: {},\n});\n\nconst xml = json2xml(json);\nconsole.log(xml);\n```\n\nDefault config is:\n\n```\nconst config = {\n  root: 'root',\n  indent: '\\t',\n  exclude: [],\n  minify: false,\n  singulars: {},\n  declaration: '<?xml version=\"1.0\" encoding=\"UTF-8\"?>'\n}\n```\n\n- `root` - root element name, default value is `'root'`\n- `indent` - indent string, default is `'\\t'`\n- `exclude` - array of keys that should be ignored e.g. `['_id']`, default is []\n- `minify` - minify xml, default is `false`, in case it is true `indent` will be ignored\n- `singulars` - dictionary for list elements, default is {} and be default in case of `cars` it will be `car` (removes last symbol from the key name)\n- `declaration` - add xml declaration, default is `<\\?xml version=\"1.0\" encoding=\"UTF-8\"\\?>`\n\ne.g.\n\n```\nconst config = {\n  root: 'secret-data',\n  indent: '    ',\n  exclude: ['age', 'salary', 'password'],\n  minify: false,\n  singulars: {\n    people: 'person'\n  }\n}","readmeFilename":"README.md"}