fast-xml-parser 4.0.7 → 4.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +10 -8
- package/package.json +1 -1
- package/src/xmlparser/OrderedObjParser.js +27 -9
- package/src/xmlparser/node2json.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library.
|
|
2
2
|
|
|
3
|
+
**4.0.8 / 2022-03-18**
|
|
4
|
+
* Fix CDATA parsing returning empty string when value = 0 (#451) (By [ndelanou](https://github.com/ndelanou))
|
|
5
|
+
* Fix stopNodes when same tag appears inside node (#456) (By [patrickshipe](https://github.com/patrickshipe))
|
|
6
|
+
* fix #468: prettify own properties only
|
|
7
|
+
|
|
3
8
|
**4.0.7 / 2022-03-18**
|
|
4
9
|
* support CDATA even if tag order is not preserved
|
|
5
10
|
* support Comments even if tag order is not preserved
|
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++ based libraries and no callback.
|
|
13
13
|
|
|
14
|
+
> Looking for maintainers
|
|
15
|
+
|
|
14
16
|
<a href="https://opencollective.com/fast-xml-parser/donate" target="_blank">
|
|
15
17
|
<img src="https://opencollective.com/fast-xml-parser/donate/button@2x.png?color=blue" width=200 />
|
|
16
18
|
</a>
|
|
@@ -18,7 +20,7 @@ Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++
|
|
|
18
20
|
|
|
19
21
|
Check [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers) for our contributors
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
|
|
23
25
|
[](https://github.com/NaturalIntelligence/ads/)
|
|
24
26
|
## Users
|
|
@@ -102,12 +104,12 @@ In a HTML page
|
|
|
102
104
|
|
|
103
105
|
Check lib folder for different browser bundles
|
|
104
106
|
|
|
105
|
-
| Bundle Name
|
|
106
|
-
|
|
|
107
|
-
| fxbuilder.min.js
|
|
108
|
-
| fxparser.js
|
|
109
|
-
| fxparser.min.js
|
|
110
|
-
| fxp.min.js
|
|
107
|
+
| Bundle Name | Size |
|
|
108
|
+
| ------------------ | ---- |
|
|
109
|
+
| fxbuilder.min.js | 5.2K |
|
|
110
|
+
| fxparser.js | 50K |
|
|
111
|
+
| fxparser.min.js | 17K |
|
|
112
|
+
| fxp.min.js | 22K |
|
|
111
113
|
| fxvalidator.min.js | 5.7K |
|
|
112
114
|
|
|
113
115
|
### Documents
|
|
@@ -142,7 +144,7 @@ Check lib folder for different browser bundles
|
|
|
142
144
|
* **[BigBit standard](https://github.com/amitguptagwl/bigbit)** :
|
|
143
145
|
* Single text encoding to replace UTF-8, UTF-16, UTF-32 and more with less memory.
|
|
144
146
|
* Single Numeric datatype alternative of integer, float, double, long, decimal and more without precision loss.
|
|
145
|
-
* **[Cytorus](https://github.com/NaturalIntelligence/cytorus)**:
|
|
147
|
+
* **[Cytorus](https://github.com/NaturalIntelligence/cytorus)**: Be specific and flexible while running E2E tests.
|
|
146
148
|
* Run tests only for a particular User Story
|
|
147
149
|
* Run tests for a route or from a route
|
|
148
150
|
* Customizable reporting
|
package/package.json
CHANGED
|
@@ -251,7 +251,7 @@ const parseXml = function(xmlData) {
|
|
|
251
251
|
currentNode.add(this.options.cdataPropName, [ { [this.options.textNodeName] : tagExp } ]);
|
|
252
252
|
}else{
|
|
253
253
|
let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true);
|
|
254
|
-
if(
|
|
254
|
+
if(val == undefined) val = "";
|
|
255
255
|
currentNode.add(this.options.textNodeName, val);
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -486,17 +486,35 @@ function readTagExp(xmlData,i, removeNSPrefix, closingChar = ">"){
|
|
|
486
486
|
*/
|
|
487
487
|
function readStopNodeData(xmlData, tagName, i){
|
|
488
488
|
const startIndex = i;
|
|
489
|
+
// Starting at 1 since we already have an open tag
|
|
490
|
+
let openTagCount = 1;
|
|
491
|
+
|
|
489
492
|
for (; i < xmlData.length; i++) {
|
|
490
|
-
if( xmlData[i] === "<"
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
493
|
+
if( xmlData[i] === "<"){
|
|
494
|
+
if (xmlData[i+1] === "/") {
|
|
495
|
+
const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);
|
|
496
|
+
let closeTagName = xmlData.substring(i+2,closeIndex).trim();
|
|
497
|
+
if(closeTagName === tagName){
|
|
498
|
+
openTagCount--;
|
|
499
|
+
if (openTagCount === 0) {
|
|
500
|
+
return {
|
|
501
|
+
tagContent: xmlData.substring(startIndex, i),
|
|
502
|
+
i : closeIndex
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
i=closeIndex;
|
|
507
|
+
} else {
|
|
508
|
+
const tagData = readTagExp(xmlData, i, '>')
|
|
509
|
+
|
|
510
|
+
if (tagData) {
|
|
511
|
+
const openTagName = tagData && tagData.tagName;
|
|
512
|
+
if (openTagName === tagName) {
|
|
513
|
+
openTagCount++;
|
|
514
|
+
}
|
|
515
|
+
i=tagData.closeIndex;
|
|
497
516
|
}
|
|
498
517
|
}
|
|
499
|
-
i=closeIndex;
|
|
500
518
|
}
|
|
501
519
|
}//end for loop
|
|
502
520
|
}
|
|
@@ -46,9 +46,9 @@ function compress(arr, options, jPath){
|
|
|
46
46
|
else val = "";
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
if(compressedObj[property] !== undefined) {
|
|
49
|
+
if(compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {
|
|
50
50
|
if(!Array.isArray(compressedObj[property])) {
|
|
51
|
-
|
|
51
|
+
compressedObj[property] = [ compressedObj[property] ];
|
|
52
52
|
}
|
|
53
53
|
compressedObj[property].push(val);
|
|
54
54
|
}else{
|