0

`Input:-

{"id":
{
 "items" : [
{
"merchant_ref": "icici",
"transaction_tag": "sdfhisdb",
"transaction_type": "balance_inquiry",
"method": "valuelink",
"order_number": "123",
"amount": "1000",
"currency_code": "CAD",
"token": {
  "token_type": "",
  "token_data": {
    "type": "",
    "value": "",
    "cardholder_name": "",
    "exp_date": ""
  }
},
{
"merchant_ref": "icici",
"transaction_tag": "sdfhisdb",
"transaction_type": "balance_inquiry",
"method": "valuelink",
"order_number": "123",
"amount": "2000",
"currency_code": "",
"token": {
  "token_type": "",
  "token_data": {
    "type": "",
    "value": "",
    "cardholder_name": "",
    "exp_date": ""
  }
},  
{
"merchant_ref": "icici",
"transaction_tag": "sdfhisdb",
"transaction_type": "authorize",
"method": "token",
"order_number": "123",
"amount": "3000",
"currency_code": "",
"token": {
  "token_type": "",
  "token_data": {
    "type": "",
    "value": "",
    "cardholder_name": "",
    "exp_date": ""
  }
}

] } }`

Output:- without any Null B, because I need to do to another mapping on the basis of this output with no Null B

<A>
  <B>
    <merchant_ref>icici</merchant_ref>
    <transaction_tag>sdfhisdb</transaction_tag>
    <transaction_type>balance_inquiry</transaction_type>
    <method>valuelink</method>
    <order_number>123</order_number>
    <amount>1000</amount>
    <currency_code>CAD</currency_code>
    <token>
      <token_type></token_type>
      <token_data>
        <type></type>
        <value></value>
        <cardholder_name></cardholder_name>
        <exp_date></exp_date>
      </token_data>
    </token>
  </B>
  <B>
    <merchant_ref>icici</merchant_ref>
    <transaction_tag>sdfhisdb</transaction_tag>
    <transaction_type>balance_inquiry</transaction_type>
    <method>valuelink</method>
    <order_number>123</order_number>
    <amount>2000</amount>
    <currency_code></currency_code>
    <token>
      <token_type></token_type>
      <token_data>
        <type></type>
        <value></value>
        <cardholder_name></cardholder_name>
        <exp_date></exp_date>
      </token_data>
    </token>
  </B>
</A>

rying to check the content of xml using the below dataweave but getting output as null B like Please suggest how to avoid this. as I need to do another point to point mapping from xml to xml for each element but that Mapping is creating an extra map where B is null also.

Please suggest how to avoid this

%dw 1.0
%output application/xml
---

A: payload.id.*items mapObject
{
	
      	B:$  when $.method=="valuelink"      
      
      otherwise {
      	
      }
     }

4

1 回答 1

0

下面应该工作。请注意, B:$ 由 () 封装,这意味着,仅当“何时”条件为真时,才将此属性包含在输出中。

%dw 1.0
%output application/xml
---
{
    A: payload.A.*B mapObject {
        (B:$) when $.method == 'valuelink'
    }
}
于 2016-03-17T14:48:31.100 回答