JSPM

icp-json2xml

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q35364F

Simple JavaScript Object to XML string converter.

Package Exports

  • icp-json2xml

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 (icp-json2xml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-json2xml

Description

Simple JavaScript Object to XML string converter.

Installation

Simplest way to install json2xml is to use npm, just npm install json2xml which will download json2xml and all dependencies.

Simple usage

var json2xml = require('json2xml');
json2xml(json, options);

Options & Behaviour

none:
json2xml({ a: 1 });
//<a>1</a>

empty node:
json2xml({ a: '' });
//<a/>

add header:
json2xml({ a: 1 }, { header: true });
//<?xml version="1.0" encoding="UTF-8"?><a>1</a>

add node attributes:
json2xml({ a: 1, attr: { b: 2, c: 3 } }, { attributes_key: 'attr' });	
// <a b="2" c="3" >1</a>

arrays:
json2xml([ { a: 1 }, { b: 2 } ]);
//'<a>1</a><b>2</b>

json2xml({ 'items': [ { item: 1 }, { item: 2 } ] });
//'<items><item>1</item><item>2</item></items>'