-
-
Notifications
You must be signed in to change notification settings - Fork 334
Closed
Description
fast-xml-parser parses the xml in an intelligent way. This is awesome. See these examples:
XML with multiple values:
<complies>
<standard>STD1</standard>
<standard>STD2</standard>
</complies>
in json:
{
"complies": {
"standard": [
"STD1",
"STD2"
]
}
}
XML with single value:
<complies>
<standard>STD1</standard>
</complies>
in json:
{
"complies": {
"standard": "STD1"
}
}
My feature-request is to add an option to force keeping the array also for single values to normalize the whole xml. An option with the default value false
to keep the current behavior as prefered behavior.
The new option could be named doNotUnwrapSingleValue
or something like this. The export for single values in xml should result in this json:
{
"complies": {
"standard": ["STD1"]
}
}
Why?
Because every node has the same structure.
Note:
This does not affect the root node. The root node never have multiple values. (tested in xml2js)
What do you think about my suggestion?
fast-xml-parser
version: 3.12.20
hug0b
Metadata
Metadata
Assignees
Labels
No labels