我正在使用节点包 xml-js 将 SOAP 响应转换为 json。
下面详细介绍了我在两个不同请求中得到的文本元素响应。
如何更改每种情况下的响应?
1. 回应
{
"declaration": {
"attributes": {
"version": "1.0",
"encoding": "utf-8"
}
},
"elements": [
{
"type": "element",
"name": "Envelope",
"attributes": {
"xmlns:soap": "http://schemas.xmlsoap.org/soap/envelope/",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"xmlns:xsd": "http://www.w3.org/2001/XMLSchema"
},
"elements": [
{
"type": "element",
"name": "Body",
"elements": [
{
"type": "element",
"name": "FetchCustResponse",
"attributes": {
"xmlns": "http://DC_API/vproxy/"
},
"elements": [
{
"type": "element",
"name": "FetchCustResult",
"elements": [
{
"type": "text",
"text": "00_AccountNo: 242734005790, AccountType: 1, Address: Cell:340397882, Balance: 0.00, ContactNo: Cell:01039788200, MeterNo: 11178005790, MinAmount: 11,715.40, Name: David James"
}
]
}
]
}
]
}
]
}
]
}
文本元素值的所需输出
"text" : {
"AccountNo": "04278005790",
"AccountType": "1",
"Address": "08039788217",
"Balance": "0.00",
"ContactNo": "08039788217",
"MeterNo": "04278005790",
"MinAmount": "11,715.40",
"Name": "David James"
}
2.
回复
{
"declaration": {
"attributes": {
"version": "1.0",
"encoding": "utf-8"
}
},
"elements": [
{
"type": "element",
"name": "Envelope",
"attributes": {
"xmlns:soap": "http://schemas.xmlsoap.org/soap/envelope/",
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"xmlns:xsd": "http://www.w3.org/2001/XMLSchema"
},
"elements": [
{
"type": "element",
"name": "Body",
"elements": [
{
"type": "element",
"name": "FetchUsageResponse",
"attributes": {
"xmlns": "http://DC_API/vproxy/"
},
"elements": [
{
"type": "element",
"name": "FetchUsageResult",
"elements": [
{
"type": "text",
"text": "00_<NewDataSet>\r\n <Table>\r\n <ID>9872686</ID>\r\n <AccountNo>04278005790</AccountNo>\r\n <MeterNo>90278005790</MeterNo>\r\n <AccounType>1</AccounType>\r\n <PINs>5539</PINs>\r\n <TotalAmount>4900.00</TotalAmount>\r\n <CreditedAmount>4802.00</CreditedAmount>\r\n <FleetComm>9.80</FleetComm>\r\n <DealerComm>73.50</DealerComm>\r\n <BankComm>14.70</BankComm>\r\n <Date>2021-04-24T16:32:36.4+01:00</Date>\r\n <IDWebTrans>13385836</IDWebTrans>\r\n <NoOfCards>1</NoOfCards>\r\n <BUID>12</BUID>\r\n <TxnReference>BD069419</TxnReference>\r\n <Token>24559787672457451531</Token>\r\n <TokeUnit>195.70</TokeUnit>\r\n <TokenAmt>4558.14</TokenAmt>\r\n <Charges>341.86</Charges>\r\n </Table>\r\n <Table>\r\n <ID>9763409</ID>\r\n <AccountNo>04278005790</AccountNo>\r\n <MeterNo>90278005790</MeterNo>\r\n <AccounType>1</AccounType>\r\n <PINs>5539</PINs>\r\n <TotalAmount>5000.00</TotalAmount>\r\n <CreditedAmount>4900.00</CreditedAmount>\r\n <FleetComm>10.00</FleetComm>\r\n <DealerComm>75.00</DealerComm>\r\n <BankComm>15.00</BankComm>\r\n <Date>2021-04-06T12:35:17.367+01:00</Date>\r\n <IDWebTrans>13270588</IDWebTrans>\r\n <NoOfCards>1</NoOfCards>\r\n <BUID>12</BUID>\r\n <TxnReference>108969129</TxnReference>\r\n <Token>17218654018179855270</Token>\r\n <TokeUnit>118.40</TokeUnit>\r\n <TokenAmt>2520.93</TokenAmt>\r\n <Charges>2479.07</Charges>\r\n </Table>\r\n</NewDataSet>"
}
]
}
]
}
]
}
]
}
]
}
文本元素值的所需输出
对象数组
请问有什么指针、解决方案或提示吗?