Skip to content

Commit d640043

Browse files
committed
fixed jshint errors
1 parent c7b702e commit d640043

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

js/xml2json.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,54 @@
33
*
44
* @example var json = $.xml2json(response);
55
*/
6-
(function(){
7-
jQuery.extend({
6+
(function() {
7+
jQuery.extend({
88

9-
/**w
10-
* Converts an xml response object from a $.ajax() call to a JSON object.
11-
*
12-
* @param xml
13-
*/
14-
xml2json: function xml2json(xml) {
15-
var result = {};
9+
/**w
10+
* Converts an xml response object from a $.ajax() call to a JSON object.
11+
*
12+
* @param xml
13+
*/
14+
xml2json: function xml2json(xml) {
15+
var result = {};
1616

17-
for(var i in xml.childNodes) {
18-
var node = xml.childNodes[i];
19-
if(node.nodeType == 1) {
20-
var child = node.hasChildNodes() ? xml2json(node) : node.nodevalue;
21-
child = child == null ? {} : child;
17+
for (var i in xml.childNodes) {
18+
var node = xml.childNodes[i];
19+
if (node.nodeType === 1) {
20+
var child = node.hasChildNodes() ? xml2json(node) : node.nodevalue;
21+
child = child === null ? {} : child;
2222

23-
if(result.hasOwnProperty(node.nodeName)) {
24-
// For repeating elements, cast/promote the node to array
25-
if(!(result[node.nodeName] instanceof Array)){
26-
var tmp = result[node.nodeName];
27-
result[node.nodeName] = [];
28-
result[node.nodeName].push(tmp);
29-
}
30-
result[node.nodeName].push(child);
31-
} else {
32-
result[node.nodeName] = child;
33-
}
23+
if (result.hasOwnProperty(node.nodeName)) {
24+
// For repeating elements, cast/promote the node to array
25+
if (!(result[node.nodeName] instanceof Array)) {
26+
var tmp = result[node.nodeName];
27+
result[node.nodeName] = [];
28+
result[node.nodeName].push(tmp);
29+
}
30+
result[node.nodeName].push(child);
31+
} else {
32+
result[node.nodeName] = child;
33+
}
3434

35-
// Add attributes if any
36-
if(node.attributes.length > 0) {
37-
result[node.nodeName]['@attributes'] = {};
38-
child['@attributes'] = {};
39-
for(var j in node.attributes) {
40-
var attribute = node.attributes.item(j);
41-
child['@attributes'][attribute.nodeName] = attribute.value;
42-
}
43-
}
35+
// Add attributes if any
36+
if (node.attributes.length > 0) {
37+
result[node.nodeName]['@attributes'] = {};
38+
child['@attributes'] = {};
39+
for (var j in node.attributes) {
40+
var attribute = node.attributes.item(j);
41+
child['@attributes'][attribute.nodeName] = attribute.value;
42+
}
43+
}
4444

45-
// Add element value
46-
if(node.childElementCount == 0 && node.textContent != null && node.textContent != "") {
47-
child.value = node.textContent.trim();
48-
}
49-
}
50-
}
45+
// Add element value
46+
if (node.childElementCount === 0 && node.textContent !== null && node.textContent !== "") {
47+
child.value = node.textContent.trim();
48+
}
49+
}
50+
}
5151

52-
return result;
53-
}
52+
return result;
53+
}
5454

55-
});
55+
});
5656
})();

0 commit comments

Comments
 (0)