xml2js: how is the output?

后端 未结 6 734
暗喜
暗喜 2020-12-28 14:36

I m trying to use the node.js module xml2js

My code is quite simple:

function testparse(pathname, callback) {
    var parser = require(\'xml2js\').Pa         


        
6条回答
  •  旧时难觅i
    2020-12-28 15:23

    As xml2js' documentation states, you can configure the parser to not abuse of arrays, by setting the property explicitArray to false (important: it has to be a boolean value as the string "false" will just not work!)

    Example:

    var parser = new xml2js.Parser({explicitArray : false});
    

    This way, you should be able to access your JSON properties in a much easier way. I hope this helps anyone.

提交回复
热议问题