fast-xml-parser
fast-xml-parser copied to clipboard
Can we configure the value of empty node to be an empty object instead of empty string while parsing xml
Checklist
- [ ] Have you asked your question on Stackoverflow or similar forum?
- [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?
Input
Code
let xmlData = '<any_name></any_name>'
const parser = new XMLParser({});
let jsonObj = parser.parse(xmlData);
console.log(jsonObj)
Output
{"any_name":""}
expected data
{"any_name":{}}
Would you like to work on this issue?
- [x] Yes
- [ ] No
Bookmark this repository for further updates.
With the current implementation, No. But we can think about it if more people need the same feature.
Definitely a much needed feature! It should be {} by default, string breaks the whole idea of types in TypeScript.