This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.

19 lines
399 B
JavaScript
Raw Normal View History

2021-04-02 02:24:13 +03:00
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);
};