fast-xml-parser
Advanced tools
Comparing version 4.1.3 to 4.1.4
Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library. | ||
**4.1.4 / 2023-04-08** | ||
* update typings to let user create XMLBuilder instance without options (#556) (By [Patrick](https://github.com/omggga)) | ||
* fix: IsArray option isn't parsing tags with 0 as value correctly #490 (#557) (By [Aleksandr Murashkin](https://github.com/p-kuen)) | ||
* feature: support oneListGroup to group repeated children tags udder single group | ||
**4.1.3 / 2023-02-26** | ||
@@ -4,0 +9,0 @@ * fix #546: Support complex entity value |
{ | ||
"name": "fast-xml-parser", | ||
"version": "4.1.3", | ||
"version": "4.1.4", | ||
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries", | ||
@@ -5,0 +5,0 @@ "main": "./src/fxp.js", |
@@ -57,2 +57,3 @@ # [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser) | ||
<a href="https://github.com/postmanlabs" title="postman" > <img src="https://user-images.githubusercontent.com/7692328/204835529-e9e290ad-696a-49ad-9d34-08e955704715.png" width="60px" ></a> | ||
<a href="https://github.com/react-native-community" title="React Native Community" > <img src="https://avatars.githubusercontent.com/u/20269980?v=4" width="60px" ></a> | ||
@@ -59,0 +60,0 @@ Check the list of all known users [here](./USERs.md); |
@@ -68,2 +68,3 @@ type X2jOptions = { | ||
processEntities: boolean; | ||
oneListGroup: boolean; | ||
}; | ||
@@ -98,4 +99,4 @@ type XmlBuilderOptionsOptional = Partial<XmlBuilderOptions>; | ||
export class XMLBuilder { | ||
constructor(options: XmlBuilderOptionsOptional); | ||
constructor(options?: XmlBuilderOptionsOptional); | ||
build(jObj: any): any; | ||
} |
@@ -36,2 +36,3 @@ 'use strict'; | ||
// transformAttributeName: false, | ||
oneListGroup: false | ||
}; | ||
@@ -107,2 +108,3 @@ | ||
const arrLen = jObj[key].length; | ||
let listTagVal = ""; | ||
for (let j = 0; j < arrLen; j++) { | ||
@@ -117,7 +119,15 @@ const item = jObj[key][j]; | ||
} else if (typeof item === 'object') { | ||
val += this.processTextOrObjNode(item, key, level) | ||
if(this.options.oneListGroup ){ | ||
listTagVal += this.j2x(item, level + 1).val; | ||
}else{ | ||
listTagVal += this.processTextOrObjNode(item, key, level) | ||
} | ||
} else { | ||
val += this.buildTextValNode(item, key, '', level); | ||
listTagVal += this.buildTextValNode(item, key, '', level); | ||
} | ||
} | ||
if(this.options.oneListGroup){ | ||
listTagVal = this.buildObjectNode(listTagVal, key, '', level); | ||
} | ||
val += listTagVal; | ||
} else { | ||
@@ -124,0 +134,0 @@ //nested node |
@@ -97,6 +97,18 @@ 'use strict'; | ||
function isLeafTag(obj, options){ | ||
const { textNodeName } = options; | ||
const propCount = Object.keys(obj).length; | ||
if( propCount === 0 || (propCount === 1 && obj[options.textNodeName]) ) return true; | ||
if (propCount === 0) { | ||
return true; | ||
} | ||
if ( | ||
propCount === 1 && | ||
(obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0) | ||
) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
exports.prettify = prettify; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102116
1929
205