Skip to content

Parser converting number-like strings to numbers? #17

@CaribouColin

Description

@CaribouColin

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 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions