You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following is from another issue that is closed, however it doesn't solve the issue of preserving tag values. It seems data types are set prior to when it tagValueProcessor is implemented which applies transformations to the original data, which is unexpected behavior of a parser.
let options = {
parseTagValue: false,
}
let parser = new XMLParser(options)
let object = parser.parse(`
<?xml version="1.0"?>
<any_name>
<person>
<phone>600.00</phone>
</person>
</any_name>
`)
console.info(object)
// { '?xml': '', any_name: { person: { phone: '600.00' } } }
You can also specify a custom tag parser inside the options object (tagValueProcessor property) to handle different cases based on your needs:
The output results in types set for numbers and booleans even when parseTagValue is false. The desireed effect is that all tag values are preserved as strings without any transformation. Otherwise the integrity of the data is broken.
{
"?xml": "",
"ShipNotice": {
"OrderNumber": "7659061-112-xxxxxxx-xxxxxxx",
"OrderID": 7659061, // should be string
"CustomerCode": "[email protected]",
"CustomerNotes": "",
"InternalNotes": "",
"NotesToCustomer": "",
"NotifyCustomer": true,
"LabelCreateDate": "08/09/2023 19:53",
"ShipDate": "08/09/2023",
"Carrier": "DHLGlobalMail",
"Service": "DHL SmartMail Parcel Ground",
"TrackingNumber": 4.20xxxx74811e+29, // from long string of digits, should be left string
"ShippingCost": 0, // from 0.00
"CustomField1": "",
"CustomField2": "",
"CustomField3": "",
"Recipient": {
"Name": "xxxxxxx",
"Company": "",
"Address1": "xxxxxxx",
"Address2": "",
"City": "xxxxxxx",
"State": "xx",
"PostalCode": "45807-9581",
"Country": "xx"
},
"Items": {
"Item": {
"SKU": "xxxxxxx",
"Name": "xxxxxxx",
"Quantity": 2, // should be string
"LineItemID": 9281347 // should be string
}
}
}
}
The text was updated successfully, but these errors were encountered:
We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.
The following is from another issue that is closed, however it doesn't solve the issue of preserving tag values. It seems data types are set prior to when it tagValueProcessor is implemented which applies transformations to the original data, which is unexpected behavior of a parser.
You can also specify a custom tag parser inside the
options
object (tagValueProcessor
property) to handle different cases based on your needs:Originally posted by @cecia234 in #597 (comment)
I am using the following parser options:
The output results in types set for numbers and booleans even when
parseTagValue
isfalse
. The desireed effect is that all tag values are preserved as strings without any transformation. Otherwise the integrity of the data is broken.The text was updated successfully, but these errors were encountered: