I am converting Json to XML using Data weave ....need help..
My input json:
if json value is like this
{"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..
so firstly i have to check which audiencetags is coming with value than if value is coming from blackauidence than only blackaudience will come and if value is coming from whiteaudience than whiteaudience tag will come
Please advice how to do mapping and use filter in such senarios
Cheers,
Bolver