JSON Transformation

0
Input JSON (e.g., from external API) { "hotelId": "H12345", "hotelName": "Sunrise Resort", "location": { "city": "Goa", "country": "India" }, "amenities": ["WiFi", "Pool", "Gym"], "rooms": [ { "roomType": "Deluxe", "price": 150, "currency": "USD" }, { "roomType": "Suite", "price": 250, "currency": "USD" } ] }   Desired Output JSON { "Hotel": { "Id": "H12345", "Name": "Sunrise Resort", "City": "Goa", "Country": "India", "Amenities": [ { "Name": "WiFi" }, { "Name": "Pool" }, { "Name": "Gym" } ], "RoomList": [ { "Type": "Deluxe", "Price": 150, "Currency": "USD" }, { "Type": "Suite", "Price": 250, "Currency": "USD" } ] } }   How can I transform the above input JSON into the desired nested structure using Mendix? Can this be done through a JavaScript action with custom mapping logic, or do I need to build an intermediate non-persistent entity structure and loop through the data? I'm especially unsure how to convert: The amenities array into an array of objects (with Name) The room list into a renamed and structured RoomList array
asked
1 answers
1

Hi Sukhvindra,

You can click on the link below, here, I have explained a same use case scenario, 

https://medium.com/mendix/simplifying-json-transformation-for-anychart-in-mendix-6855330aae4d

This may help you resolve the isisue,

 

Let me know, if you face any issues,

Hope it helps!

answered