UNPKG

@ibm-skills-network/xml-js

Version:

A convertor between XML text and Javascript object / JSON text.

19 lines (17 loc) 381 B
var js2xml = require('./js2xml.js'); module.exports = function (json, options) { if (json instanceof Buffer) { json = json.toString(); } var js = null; if (typeof (json) === 'string') { try { js = JSON.parse(json); } catch (e) { throw new Error('The JSON structure is invalid'); } } else { js = json; } return js2xml(js, options); };