matthewmatician / xml-flow

An XML/HTML stream reader, now with less suck!
MIT License
55 stars 18 forks source link

Arrays are returned as Object with numeric keys #14

Closed leachiM2k closed 6 years ago

leachiM2k commented 6 years ago

Hey, I've got an issue with xml-flow. Maybe it's caused by node v8's changed array/object behaviour.

My input XML is:

<?xml version="1.0" encoding="utf-8"?>
<root>
    <test>
        <line>testline</line>
        <chars>
            <item>1</item>
            <item>2</item>
        </chars>
    </test>
</root>

results in:

{
  "$name": "test",
  "line": "testline",
  "chars": {
    "0": "1",
    "1": "2"
  }
}

As you see, the resulting "chars" array is an object instead of an array.

What I expect is:

{
  "$name": "test",
  "line": "testline",
  "chars": [
    "1",
    "2"
  ]
}

I've already found a solution in helper.js -> shallowClone and could provide it to you.

Cheers Michael

matthewmatician commented 6 years ago

Thanks for the fix!