fastify-xml-body-parser
fastify-xml-body-parser copied to clipboard
Parser converting number-like strings to numbers?
One of our endpoints accepts XML and parses it into a JS object. Part of the data that it receives includes a zip code. It appears that this parser is seeing what looks like a number and converting it into an int even though zip codes should be treated as strings. Is there a way to disable the automatic parsing of values?
UPDATE: I tried setting the attribute parsing value to false but it seems to be completely ignoring the option.
fastifyServer.register(require('fastify-xml-body-parser'), {
parseAttributeValue: false,
})
Example Data:
<PostalCode>02108</PostalCode>
console.log(request.body); // { PostalCode: 2108 }
@CaribouColin this package is using FXP v4 now. It means you can set numberparseoptions to manipulate the parsing result.