NaturalIntelligence / fast-xml-parser

Validate XML, Parse XML and Build XML rapidly without C/C++ based libraries and no callback.
https://naturalintelligence.github.io/fast-xml-parser/
MIT License
2.49k stars 302 forks source link

Can we configure the value of empty node to be an empty object instead of empty string while parsing xml #502

Open qbert-007 opened 1 year ago

qbert-007 commented 1 year ago

Checklist

### 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?

Bookmark this repository for further updates.

amitguptagwl commented 1 year ago

With the current implementation, No. But we can think about it if more people need the same feature.

nikimicallef commented 1 year ago

Definitely a much needed feature! It should be {} by default, string breaks the whole idea of types in TypeScript.