Any recommendation for xml to json for Node.js?

前端 未结 8 733
面向向阳花
面向向阳花 2020-12-08 15:14

I\'ve installed node-xml but I don\'t think it works the way I expect. and it doesnt\' have example. any recommendation for xml-2-json (js) for node.js? I also looked a

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 15:25

    To convert XML to JSON in Node js, you can use xml2json package.

    To install the package:- npm install --save xml2json

    Add Code snippet:-

    var parser = require('xml2json');
    
    var xml = "bar";
    console.log("input -> %s", xml)
    
    // xml to json
    var json = parser.toJson(xml);
    console.log("to json -> %s", json);
    

    For more details please visit:- xml2json

提交回复
热议问题