AnsweredAssumed Answered

How to set empty array element to JSON output/response profile ?

Question asked by amudhavani.shanthosh181426 on Aug 20, 2018
Latest reply on Aug 20, 2018 by DarrellFlenniken9941

Hi,

 

My output is as follows

 

{
"items": [{
"objectNumber": "101000001",
"discounts": [{
"id": 10102,
"name": "Free Perks Bev",
"price": -10.69
}]
},
{
"objectNumber": "101000002"
}
]
}

 

For the first item "101000001" discount is applied and for the second item "101000002", discount is not applied. 

In this scenario, the customer expects the output as highlighted below with an empty array for the discount array for the second item.

 

{
"items": [{
"objectNumber": "101000001",
"discounts": [{
"id": 10102,
"name": "Free Perks Bev",
"price": -10.69
}]
},
{
"objectNumber": "101000002",

"discounts": []
}
]
}

 

I tried but looks like there is no such option. Can you please help to achieve this. Thanks.

Outcomes