初始化
This commit is contained in:
22
node_modules/xml-js/lib/xml2json.js
generated
vendored
Normal file
22
node_modules/xml-js/lib/xml2json.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var helper = require('./options-helper');
|
||||
var xml2js = require('./xml2js');
|
||||
|
||||
function validateOptions (userOptions) {
|
||||
var options = helper.copyOptions(userOptions);
|
||||
helper.ensureSpacesExists(options);
|
||||
return options;
|
||||
}
|
||||
|
||||
module.exports = function(xml, userOptions) {
|
||||
var options, js, json, parentKey;
|
||||
options = validateOptions(userOptions);
|
||||
js = xml2js(xml, options);
|
||||
parentKey = 'compact' in options && options.compact ? '_parent' : 'parent';
|
||||
// parentKey = ptions.compact ? '_parent' : 'parent'; // consider this
|
||||
if ('addParent' in options && options.addParent) {
|
||||
json = JSON.stringify(js, function (k, v) { return k === parentKey? '_' : v; }, options.spaces);
|
||||
} else {
|
||||
json = JSON.stringify(js, null, options.spaces);
|
||||
}
|
||||
return json.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
||||
};
|
||||
Reference in New Issue
Block a user