1、首先在目录结构中引入必要的js文件
https://files.cnblogs.com/files/qianyou304/x2j.rar
2、js中代码如下:(部分)json 2 xml
var X2JS = require(‘../../lib/x2js/we-x2js‘); var loginJson = { "Name": "LOGIN", "Info": { "userName": "test001", "password": "000000", "accessTime": "2019-09-12 15:19:40" } } var x2js = new X2JS();
var loginXml = x2js.js2xml(loginJson);
3、xml 2 json以此类推即可