NodeJS-SoapRequest输出

时间:2019-03-08 18:57:41

标签: node.js

我们有一个肥皂请求(如果完成),它会返回以下响应:

soap.createClient(url, function(err, soapClient){
soapClient.ReadParameter({
    email : config.get('Studer.main.email'), 
    pwd : config.get('Studer.main.pwd'),
    installationNumber : config.get(`Studer.config_${_client}.installationNumber`),
    device : config.get(`Studer.set${_gParam}.device`),
    paramId : config.get(`Studer.set${_gParam}.paramId`),
    paramPart : config.get(`Studer.set${_gParam}.paramPart`)
    //userLevelCode : config.get('Studer.main.userLevelCode')
  }, function(err, answer){
    console.log(answer);    
    console.log(JSON.stringify(answer));
    });
if (debug == true ){console.log(soapClient.lastRequest)};
});

控制台输出类似于
console.log(answer)

{ ReadParameterResult:
{ UIntValue: '1',
 FloatValue: '1',
 ErrorCode: 1,
 ErrorMessage: 'OK',
 ScomFormatNo: 0 } }

console.log(JSON.stringify(answer));

{"ReadParameterResult":{"UIntValue":"1","FloatValue":"1","ErrorCode":1,"ErrorMessage":"OK","ScomFormatNo":0}}

问题是我该如何解析此输出,以便将“ FloatValue”或“ ErrorCode”转换为变量?

0 个答案:

没有答案