I have a sample JSON as follows. I have to map this object to another JSON format which is canonical to the UI (getting different orders from different vendors and aggregating them to a common UI format).
If I generate POJOs, it will create Order_1, Order_2... classes under the outer class which looks dirty. And during development time, I may not be able to anticipate how many orders may come during peak. So how do I approach this problem?
My end result should be able to map this JSON to the target JSON where repeatable elements are arrays.
{
"TotalOrders": 6,
"Order_1": {
"Item_1": {
"item": "Shirt",
"Quantity": 2
},
"Item_2": {
"item": "Jeans",
"Quantity": 2
}
},
"Order_2": {
"Item_1": {
"item": "Caps",
"Quantity": 2
},
"Item_2": {
"item": "Bags",
"Quantity": 2
},
"Item_3": {
"item": "Chains",
"Quantity": 2
}
},
"Order_3": {
"Item_1": {
"item": "Watches",
"Quantity": 2
},
"Item_2": {
"item": "Rings",
"Quantity": 2
},
"Item_3": {
"item": "Perfumes",
"Quantity": 2
},
"Item_4": {
"item": "Deo",
"Quantity": 1
}
},
"Order_4": {
"Item_1": {
"item": "Cans",
"Quantity": 2
},
"Item_2": {
"item": "Tubes",
"Quantity": 2
},
"Item_3": {
"item": "Tents",
"Quantity": 2
}
},
"Order_5": {
"Item_1": {
"item": "Butter",
"Quantity": 2
},
"Item_2": {
"item": "Jam",
"Quantity": 2
},
"Item_3": {
"item": "Bread",
"Quantity": 2
}
},
"Order_6": {
"Item_1": {
"item": "DVD",
"Quantity": 2
},
"Item_2": {
"item": "Floppy",
"Quantity": 2
},
"Item_3": {
"item": "Cables",
"Quantity": 2
}
}
}