@rea-jet/rea-xml2js
Advanced tools
Comparing version 3.1.0 to 3.2.0-rc0
@@ -8,2 +8,3 @@ var fastXmlParser = require('@rea-jet/fast-xml-parser'); | ||
module.exports = XML2JS; | ||
const XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'; | ||
@@ -51,3 +52,4 @@ function XML2JS() { | ||
// default is a=>a | ||
sortkey: '#index' | ||
sortkey: '#index', | ||
xmldesc: true | ||
}; | ||
@@ -80,7 +82,6 @@ var clazz = this; | ||
return new Promise((res, rej) => { | ||
let opts = Object.assign({}, optionsToXML, options); | ||
var parser = new ParserToXml(opts); | ||
var xml = parser.parse(json); | ||
xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n' + xml; | ||
res(xml); | ||
const opts = Object.assign({}, optionsToXML, options); | ||
const parser = new ParserToXml(opts); | ||
const xml = parser.parse(json); | ||
return res(opts.xmldesc ? `${XML_HEADER}$xml}` : xml); | ||
}); | ||
@@ -87,0 +88,0 @@ } |
@@ -13,3 +13,3 @@ const fs = require('fs'); | ||
explicitChildren: false, | ||
sortkey: '#index', | ||
sortkey: '#index' | ||
}; | ||
@@ -22,44 +22,17 @@ | ||
explicitChildren: true, | ||
sortkey: '#index', | ||
sortkey: '#index' | ||
}; | ||
// let xml = fs.readFileSync('./assets/demolabel_1ph.xml').toString(); | ||
// let xml = fs.readFileSync('./assets/child-node.xml').toString(); | ||
let xml = fs.readFileSync('./assets/child-node.xml').toString(); | ||
// xml2js | ||
// .toJSON(xml, defaultParseOptions) | ||
// .tap(json => console.log(JSON.stringify(json, null, ' '))) | ||
// .then(json => xml2js.toXML(json, defaultBuilderOptions)) | ||
// // .tap(xmlOut => console.log(typeof xmlOut, typeof xml)) | ||
// // .then(xmlOut => console.log(diff(xml, xmlOut))) | ||
// // .tap(xmlOut => console.log(xmlOut)) | ||
// .catch(e => console.log(e)); | ||
xml2js | ||
.toJSON(xml, defaultParseOptions) | ||
.tap(json => console.log(JSON.stringify(json, null, ' '))) | ||
.then(json => xml2js.toXML(json, defaultBuilderOptions)) | ||
// .tap(xmlOut => console.log(typeof xmlOut, typeof xml)) | ||
// .then(xmlOut => console.log(diff(xml, xmlOut))) | ||
// .tap(xmlOut => console.log(xmlOut)) | ||
.catch(e => console.log(e)); | ||
// setInterval(() => {}, 1000); | ||
const data = { | ||
test: { | ||
Entry: [ | ||
{ Reference: 'test', Value: 'abc02', '#index': 0 }, | ||
{ Reference: 'test', Value: 'abc03', '#index': 1 }, | ||
{ Reference: 'test', Value: 'abc04', '#index': 2 }, | ||
{ Reference: 'test', Value: 'abc05', '#index': 3 }, | ||
{ Reference: 'test', Value: 'abc06', '#index': 4 }, | ||
{ Reference: 'test', Value: 'abc07', '#index': 5 }, | ||
{ Reference: 'test', Value: 'abc08', '#index': 6 }, | ||
{ Reference: 'test', Value: 'abc09', '#index': 7 }, | ||
{ Reference: 'test', Value: 'abc10', '#index': 8 }, | ||
{ Reference: 'test', Value: 'xyz02', '#index': 9 }, | ||
{ Reference: 'test', Value: 'xyz03', '#index': 10 }, | ||
{ Reference: 'test', Value: 'xyz04', '#index': 11 }, | ||
{ Reference: 'test', Value: 'xyz05', '#index': 12 }, | ||
{ Reference: 'test', Value: 'xyz06', '#index': 13 }, | ||
{ Reference: 'test', Value: 'xyz07', '#index': 14 }, | ||
{ Reference: 'test', Value: 'xyz08', '#index': 15 }, | ||
{ Reference: 'test', Value: 'xyz09', '#index': 16 }, | ||
{ Reference: 'test', Value: 'xyz10', '#index': 17 }, | ||
], | ||
}, | ||
}; | ||
xml2js.toXML(data, defaultBuilderOptions).then(console.log); |
{ | ||
"name": "@rea-jet/rea-xml2js", | ||
"version": "3.1.0", | ||
"version": "3.2.0-rc0", | ||
"description": "REA bidirectional XML to JSON converter", | ||
@@ -29,2 +29,2 @@ "main": "dist/index.js", | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18693
306
2