【发布时间】:2017-04-24 16:50:09
【问题描述】:
我正在使用 Data weave 将 Json 转换为 XML ....需要帮助..
我的输入json:
如果json值是这样的
{"whiteaudience": [
{
"audienceType": {
"Id": "70000",
"Name": "whiteau"
}
},
{
"audienceType": {
"Id": "70000",
"Name": "whiteau"
}
}
],
"blackaudience": [
{
"audienceType": {
"Id": "",
"Name": ""
}
},
{
"audienceType": {
"Id": "",
"Name": ""
}
}
]
}
thnan output XML be like
<ColuredAudience>
<whiteaudience>
<item>70000</item>
<item>70000</item>
</whiteaudience>
</ColuredAudience>
and if input json is like this
{"whiteaudience": [
{
"audienceType": {
"Id": "",
"Name": ""
}
},
{
"audienceType": {
"Id": "",
"Name": ""
}
}
],
"blackaudience": [
{
"audienceType": {
"Id": "80000",
"Name": " blackau"
}
},
{
"audienceType": {
"Id": "80000",
"Name": "blackau"
}
}
]
}
thnan output XML be like
<ColuredAudience>
<blackaudience>
<item>80000</item>
<item>80000</item>
</blackaudience>
</ColuredAudience>
So the logic is ,i will get value(s) either for whiteaudience.id or blackaudience.id so if the values is coming for whiteaudience than blackauidence tag will come with empty tag(s) and viceversa..
所以首先我必须检查哪些受众标签具有价值,而不是价值来自 blackaudience,而不是只有 blackaudience 来,如果价值来自 whiteaudience,那么 whiteaudience 标签会来
Please advice how to do mapping and use filter in such senarios
Cheers,
Bolver
【问题讨论】: