@magic-xpa/utils 4.1201.0-dev4121.307 → 4.1201.0-dev4121.308

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.
@@ -1,5 +1,5 @@
1
1
  import { Encoding, StringBuilder, Hashtable, Stack, NChar, NNumber, NString, RefParam, isNullOrUndefined, DateTime, ISO_8859_1_Encoding, ApplicationException, Int32, Exception, List, Thread, Debug } from '@magic-xpa/mscorelib';
2
- import { parseString } from 'xml2js';
2
+ import { XMLParser } from 'fast-xml-parser';
3
3
 
4
4
  /// <summary>JPN: DBCS support
5
5
  /// Utility Class for String
@@ -5020,9 +5020,30 @@ class InternalInterface {
5020
5020
  }
5021
5021
  }
5022
5022
 
5023
+ const parser = new XMLParser({
5024
+ ignoreAttributes: false,
5025
+ attributeNamePrefix: "",
5026
+ attributesGroupName: "$",
5027
+ textNodeName: "_",
5028
+ parseTagValue: false,
5029
+ parseAttributeValue: false,
5030
+ trimValues: false,
5031
+ isArray: (_name, jPath, _isLeafNode, isAttribute) => {
5032
+ if (isAttribute) {
5033
+ return false;
5034
+ }
5035
+ // Keep root object shape as xml2js default; force arrays for child elements.
5036
+ return jPath.indexOf(".") !== -1;
5037
+ }
5038
+ });
5023
5039
  class JSON_Utils {
5024
5040
  static JSONFromXML(xml, onComplete) {
5025
- parseString(xml, onComplete);
5041
+ try {
5042
+ onComplete(null, parser.parse(xml));
5043
+ }
5044
+ catch (error) {
5045
+ onComplete(error, null);
5046
+ }
5026
5047
  }
5027
5048
  }
5028
5049