JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q55392F
  • License ISC

Another json to xml convertor.

Package Exports

  • another-json-xml
  • another-json-xml/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (another-json-xml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

another json/xml converter

Converts 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. 's'.

how to install

npm install another-json-xml --save

how to use

const { json2xml } = require('another-json-xml');

const json = {
  "name": "John",
  "age": 30,
  "cars": {
    "car1": "Ford",
    "car2": "BMW",
    "car3": "Fiat"
  }
}
const xml = json2xml(json, config);

config( optional)

const config = {
  root: 'root',
  indent: '  ',
  exclude: ['_id'],
  minify: false,
  singulars: {
    'cars': 'car'
  }
}
  • root - root element name, default is 'root'
  • indent - indent string, default is '\t'
  • exclude - array of keys that should be ignored, default is []
  • minify - minify xml, default is false, in case it is true indent will be ignored
  • singulars - dictionary for list elements, default is {}, in case of cars it will be car