Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 771b3a3

Browse files
committed
fix force array global issue
1 parent 6fc4a26 commit 771b3a3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/xml2json.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ var obj = {};
88
var currentObject = {};
99
var ancestors = [];
1010
var currentElementName = null;
11-
var forceArrays = {};
1211

1312
var options = {}; //configuration options
1413
function startElement(name, attrs) {
@@ -21,7 +20,7 @@ function startElement(name, attrs) {
2120
}
2221

2322
if (! (name in currentObject)) {
24-
if(options.arrayNotation || forceArrays[name]) {
23+
if(options.arrayNotation || options.forceArrays[name]) {
2524
currentObject[name] = [attrs];
2625
} else {
2726
currentObject[name] = attrs;
@@ -153,9 +152,10 @@ module.exports = function(xml, _options) {
153152
var validation = joi.validate(_options, schema);
154153
hoek.assert(validation.error === null, validation.error);
155154
options = validation.value;
155+
options.forceArrays = {};
156156
if (Array.isArray(options.arrayNotation)) {
157157
options.arrayNotation.forEach(function(i) {
158-
forceArrays[i] = true;
158+
options.forceArrays[i] = true;
159159
});
160160
options.arrayNotation = false;
161161
}

0 commit comments

Comments
 (0)