I am facing a challenge with a JSON structure that looks like this:
"hotel": [
{
"id": 90091,
"hotelGroup": "A1",
"hotelRoom": [
{
"name":"Room1",
"minimumQuantity": 1,
"maximumQuantity": 6,
},
{
"name":"Room2",
"minimumQuantity": 7,
"maximumQuantity": 12,
}
]},
{
"id": 90089,
"hotelGroup": "A4",
"hotelRoom": [
{
"name":"Room1",
"minimumQuantity": 0,
"maximumQuantity": 0,
}]
}]
My aim is to restructure the JSON as shown below:
hotel = [{
name: "Room1",
RoomInfo: [{
hotelGroup: "A1",
Stops: [
{"minimumQuantity": 1,"maximumQuantity": 6}
]},
{
hotelGroup: "A4",
Stops: [
{"minimumQuantity": 0,"maximumQuantity": 0}
]
}
]},
{
name: "Room2",
RoomInfo: [{
Name: "A1",
Stops: [
{"minimumQuantity": 7,"maximumQuantity": 12}
]
}]
}]
If anyone has any advice or assistance on how to achieve this restructuring, it would be greatly appreciated. I am looking to group each hotel by its name and have its respective hotel group and stops nested accordingly.
Thank you in advance