-
Notifications
You must be signed in to change notification settings - Fork 609
Description
I wrote something like this:
function parseNumberProcessor(value, key) {
console.log("My NODE: "+ key + " My value: "+ value);
let isNumberNode = true;
if ('account' === key) {
isNumberNode = false;
}
if ((!isNaN(value))&&(isNumberNode)) {
value = value % 1 === 0 ? parseInt(value, 10) : parseFloat(value);
}
return value;
}
const xml = '0012345123.45';
xml2js.parseString(xml, {
valueProcessors: [parseNumberProcessor]}, function(err, result) {
console.log(result);
}
);
And the console out put is:
My NODE: undefined My value: 0012345
My NODE: undefined My value: 123.45
{ account: { accountNumber: [ 12345 ], balance: [ 123.45 ] } }
Seems valueProcessors could not accept the signature for value and key. But in the test, I see there is a similar test passed, not sure how could I handle that