fast-xml-parser icon indicating copy to clipboard operation
fast-xml-parser copied to clipboard

Integer Being Parsed to String

Open JoshuaMarden opened this issue 1 year ago • 1 comments

  • [x] Are you running the latest version?
  • [x] Have you included sample input, output, error, and expected output?
  • [x] Have you checked if you are using correct configuration?
  • [x] Did you try online tool?
  • [x] Have you checked the docs for helpful APIs and examples?

Description

XML with integer of 'nil' gets parsed to an empty string in JSON, rather than 0. Doesn't appear to be configurable.

Input

Drop this in the online parser for example:

<?xml version="1.0" encoding="UTF-8"?>
<data>
  <example-field type="integer" nil="true"/>
</data>

Code

N/A

Output

{
    "?xml": "",
    "data": {
        "example-field": ""
    }
}

expected data

{
    "?xml": "",
    "data": {
        "example-field": 0
    }
}

Would you like to work on this issue?

  • [x] Yes
  • [ ] No

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

JoshuaMarden avatar Apr 23 '25 13:04 JoshuaMarden

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.

github-actions[bot] avatar Apr 23 '25 13:04 github-actions[bot]