0

我正在使用 xml2js 节点包来解析 xml 提要。有什么办法可以防止值被方括号括起来吗?

例如 "reference": ["ABC123"] 应该是 "reference": "ABC123"

"items": [
    {
        "reference": ["ABC123"],
        "hours": ["35"]
    },
    {
        "reference": ["XYZ123"],
        "hours": ["20"]
    }
]
4

1 回答 1

0

解决方案:

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

结果是

"items": [
    {
        "reference": "ABC123",
        "hours": "35"
    },
    {
        "reference": "XYZ123",
        "hours": "20"
    }
]
于 2020-02-13T10:24:03.013 回答