Pluto
Pluto copied to clipboard
xml.decode: flat mode
The way xml.decode currently behaves is more akin to a "full" mode. It would be good to also add a "flat" mode to it, but it needs to also consider the same tag being present multiple times:
<entries>
<entry primary="">
<name>primary</name>
</entry>
<entry/>
</entries>
{
["entries"] = {
["entry"] = {
[1] = {
["__attributes"] = {
["primary"] = string(0) "",
},
["name"] = string(7) "primary",
},
[2] = {},
},
},
}
Of course, it would mean that only 1 entry would be flattened like this:
<entries>
<entry primary="">
<name>primary</name>
</entry>
</entries>
{
["entries"] = {
["entry"] = {
["__attributes"] = {
["primary"] = string(0) "",
},
["name"] = string(7) "primary",
},
},
}
Maybe adding an option to pick how "aggressive" the flattening should be could also help here.