michaelkourlas / node-js2xmlparser

Popular Node.js module for parsing JavaScript objects into XML
https://www.npmjs.org/package/js2xmlparser
Apache License 2.0
222 stars 52 forks source link

[Question] Process values during conversion. #99

Closed armoucar closed 1 year ago

armoucar commented 1 year ago

Hi, I was able to process values for Dates using the typeHandlers option. But I have a specific case where I have to format a number to have an exact amount of characters:

{
  "myNumber": 7
}
<myNumber>007<myNumber>

Is there anyway I could achieve that but specifically targeting the myNumber prop without triggering the same behavior to other number fields? Thanks

michaelkourlas commented 1 year ago

No, this isn't possible. It should be simple enough to preprocess the JSON to replace the number with an appropriate string, though.