I have sent JSON Message to backend server using WSO2 EI. But it sending wrong json format. I have used wso2ei-6.4.0 for this task. I have added sample XML request which I have used.
<jsonObject>
<checkInDate>2019-03-25</checkInDate>
<checkOutDate>2019-03-26</checkOutDate>
<cityCode>3086</cityCode>
<hotelCode />
<roomOccupancyList>
<jsonArray>
<?xml-multiple jsonElement?>
<jsonElement>
<childAges>0</childAges>
<numberOfAdults>1</numberOfAdults>
<numberOfChildren>0</numberOfChildren>
<roomNo>1</roomNo>
</jsonElement>
</jsonArray>
</roomOccupancyList>
</jsonObject>
But I got following JSON request from ESB side. Once send the message through the ESB service.
{
"checkInDate": "2019-06-04",
"checkOutDate": "2019-06-05",
"cityCode": "1344",
"hotelCode": "",
"roomOccupancyList": {
"childAges": "0",
"numberOfAdults": "1",
"numberOfChildren": "0",
"roomNo": "1"
}
}
This "roomOccupancyList" should have JSONArray Object, by default it showing as JSONObject. If I have add multiple jsonElement here, it showing as JSONArray. But I need even one jsonElement also. Can you please help me to fixed this issue. I have refereed following link for above task. wso2 doc link
JSON Response should load following format.
{
"checkInDate": "2019-06-04",
"checkOutDate": "2019-06-05",
"cityCode": "1344",
"hotelCode": "",
"roomOccupancyList": [
{
"childAges": "0",
"numberOfAdults": "1",
"numberOfChildren": "0",
"roomNo": "1"
}
]
}