Mapping API Response of Nested Json Object List in microflow
0
Hi, i have been trying to invoke a rest api where the api response is a list of json objects (sample provided below). I have tried using the import map to map my response and output it to a dataview in a page, but because of the array response, mendix is not able to map the response correctly and hence I'm unable to display the api response / manipulate the data received from the api in any manner. Is there any solution to it. api sample response - [ { "usecaseId": 2, "usecaseName": "Sample UseCase", "usecaseDescriptionLocal": "Sample UseCase Jp", "usecaseDescriptionEnglish": "Sample UseCase", "usecaseDetailLocal": "Sample UseCase Jp", "usecaseDetailEnglish": "Sample UseCase", "userLists": [ { "useCaseId": null, "ulistId": 1, "userListName": "Sample UserList", "userListDescriptionLocal": "Sample UserList Jp", "userListDescriptionEnglish": "Sample UserList", "userListDetailLocal": "Sample UserList Jp", "userListDetailEnglish": "Sample UserList test", "userListUserName": "Sample UseCase_Sample UserList", "userListPassword": "Nj11JWFxclA=", "useCustomUserName": false, "useCustomPassword": false } ] }, ] this is my current import mapping (updated) Current Microflow API Response stored to variable (ULMDetails) - can view that the userlist data is not being saved to the api response
asked
Ashish Philip
1 answers
-1
You don't need to include the Root or UserLists objects in your mapping, so you can flatten this a bit by having a 1-* association between JsonObject and UserList
When you display the data use a dataview to show the JsonObject with a listview (or similar) to show the list of UserList objects by association