fast-xml-parser 4.0.6 → 4.0.7
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 +2 -0
- package/package.json +1 -1
- package/src/xmlbuilder/json2xml.js +24 -18
- package/src/xmlbuilder/orderedJs2Xml.js +4 -1
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.7 / 2022-03-18**
|
|
4
|
+
* support CDATA even if tag order is not preserved
|
|
5
|
+
* support Comments even if tag order is not preserved
|
|
6
|
+
* fix #446: XMLbuilder should not indent XML declaration
|
|
7
|
+
|
|
3
8
|
**4.0.6 / 2022-03-08**
|
|
4
9
|
* fix: call tagValueProcessor only once for array items
|
|
5
10
|
* fix: missing changed for #437
|
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++
|
|
|
18
18
|
|
|
19
19
|
Check [ThankYouBackers](https://github.com/NaturalIntelligence/ThankYouBackers) for our contributors
|
|
20
20
|
|
|
21
|
+
>Want to focus more on opensource, further study, and family. So open for part-time good job in technical architect, node js backend developer, research assistant, or IT teacher. https://amitkumargupta.work/
|
|
22
|
+
|
|
21
23
|
[](https://github.com/NaturalIntelligence/ads/)
|
|
22
24
|
## Users
|
|
23
25
|
|
package/package.json
CHANGED
|
@@ -172,11 +172,10 @@ function buildObjectNode(val, key, attrStr, level) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
if (attrStr && val.indexOf('<') === -1) {
|
|
175
|
-
return (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
} else {
|
|
175
|
+
return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );
|
|
176
|
+
} else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
|
|
177
|
+
return this.indentate(level) + `<!--${val}-->` + this.newLine;
|
|
178
|
+
}else {
|
|
180
179
|
return (
|
|
181
180
|
this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +
|
|
182
181
|
val +
|
|
@@ -194,20 +193,27 @@ function buildEmptyObjNode(val, key, attrStr, level) {
|
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
function buildTextValNode(val, key, attrStr, level) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if(this.options.suppressUnpairedNode){
|
|
202
|
-
return this.indentate(level) + '<' + key + this.tagEndChar;
|
|
203
|
-
}else{
|
|
204
|
-
return this.indentate(level) + '<' + key + "/" + this.tagEndChar;
|
|
205
|
-
}
|
|
196
|
+
if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
|
|
197
|
+
return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
|
|
198
|
+
}else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
|
|
199
|
+
return this.indentate(level) + `<!--${val}-->` + this.newLine;
|
|
206
200
|
}else{
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
201
|
+
let textValue = this.options.tagValueProcessor(key, val);
|
|
202
|
+
textValue = this.replaceEntitiesValue(textValue);
|
|
203
|
+
|
|
204
|
+
if( textValue === '' && this.options.unpairedTags.indexOf(key) !== -1){ //unpaired
|
|
205
|
+
if(this.options.suppressUnpairedNode){
|
|
206
|
+
return this.indentate(level) + '<' + key + this.tagEndChar;
|
|
207
|
+
}else{
|
|
208
|
+
return this.indentate(level) + '<' + key + "/" + this.tagEndChar;
|
|
209
|
+
}
|
|
210
|
+
} else{
|
|
211
|
+
return (
|
|
212
|
+
this.indentate(level) + '<' + key + attrStr + '>' +
|
|
213
|
+
textValue +
|
|
214
|
+
'</' + key + this.tagEndChar );
|
|
215
|
+
}
|
|
216
|
+
|
|
211
217
|
}
|
|
212
218
|
}
|
|
213
219
|
|
|
@@ -41,7 +41,10 @@ function arrToStr(arr, options, jPath, level){
|
|
|
41
41
|
continue;
|
|
42
42
|
}else if( tagName[0] === "?"){
|
|
43
43
|
const attStr = attr_to_str(tagObj[":@"], options);
|
|
44
|
-
|
|
44
|
+
const tempInd = tagName === "?xml" ? "" : indentation;
|
|
45
|
+
let piTextNodeName = tagObj[tagName][0][options.textNodeName];
|
|
46
|
+
piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : ""; //remove extra spacing
|
|
47
|
+
xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`;
|
|
45
48
|
continue;
|
|
46
49
|
}
|
|
47
50
|
const attStr = attr_to_str(tagObj[":@"], options);
|