1

i'm using the xml2js node package to parse an xml feed. Is there any way to prevent the values being surrounded by square brackets?

E.g. "reference": ["ABC123"] should be "reference": "ABC123"

"items": [
    {
        "reference": ["ABC123"],
        "hours": ["35"]
    },
    {
        "reference": ["XYZ123"],
        "hours": ["20"]
    }
]
Scott
  • 1,280
  • 4
  • 20
  • 35

1 Answers1

3

Solution:

var xml2js = require('xml2js').Parser({explicitArray : false});

results in

"items": [
    {
        "reference": "ABC123",
        "hours": "35"
    },
    {
        "reference": "XYZ123",
        "hours": "20"
    }
]
Scott
  • 1,280
  • 4
  • 20
  • 35