在Informatica集成分配步骤中支持可选参数

问题描述 投票:1回答:1

我当前的实现请求正文不支持可选属性:

enter image description here

[如果说phoneHomenull,则想要的行为是JSON根本不包含属性,例如我想要的是:

{ 
    "phoneWork": "value here",
    "phoneMobile": "value here",
    "email": "value here"
}

不是:

{ 
    "phoneHome": "",
    "phoneWork": "value here",
    "phoneMobile": "value here",
    "email": "value here"
}

我已经尝试遍历事件中的所有元素,并且仅返回不为null的值,但是我无法使其正常工作。伪代码:

for $i in
(
    $input.event_input[1]/xxx_Contact_Work_PHONE__c,
    $input.event_input[1]/xxx_Contact_Home_PHONE__c,
    $input.event_input[1]/xxx_Contact_Mobile_PHONE__c,
    $input.event_input[1]/xxx_Contact_Contact_EMAIL1__c 
)
return if ($i = "null")
then do nothing
else add the attribute to a JSON

有没有办法做到这一点?

informatica informatica-cloud
1个回答
0
投票

下面的公式,当以XML作为输入时,将删除所有没有数据的元素。

示例

使用以下输入

<note>
  <to>Tove</to>
  <from></from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
  <element></element>
</note>

它产生以下输出

<note>
  <to>Tove</to>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

这是我找到的解决方案:

let $sources:=$input.XML_input 
let $labels:=fn:distinct-values($sources/*/fn:node-name(.))
return
for $s in $sources
    return 
    <source>
    {
    for $l in $labels
        return 
        if (fn:exists($s/*[fn:node-name()=$l]/text()))
        then ($s/*[fn:node-name()=$l])
        else ""
    }
    </source>
© www.soinside.com 2019 - 2024. All rights reserved.