How to Implement Best Import Mapping Strategy for Complex JSON

0
Hi,   We would like to import mapping a list of task content as outlined below, so that requests can be approved or rejected directly within the portal. However, we are encountering challenges at the import mapping stage.   Key points of our situation: We have more than 10 systems to integrate. Each request type differs from the others. All form data is received within a contentData structure. We would prefer not to maintain a single, monolithic contentData entity, as scaling to 100+ attributes would make management difficult as new task sources are added (also manipulating json may consequent with errors). Instead, we would like to store contentData objects through different associations.   Our question: How can we best import mapping this type of data? We are considering implementing specializations of contentData using inheritance, but we are not certain if this is the most effective approach.   [ {     "taskSource": "EmployeeLeave",     "subject": "John Doe - Leave Form Approval",     "summary": "John Doe- Leave Form First Manager Approval ",     "contentData": {         "formId": 3333         "employee": "John Doe",         "employeeID": "4500"     }, {     "taskSource": "SAPTravel",     "subject": "Jane Doe - Car Request Approval",     "summary": "Jane Doe - Car Request First Manager Approval ",     "contentData": {         "requestid": 121         "requestor": "Jane Doe",         "driver": "Transporter",         "car":"2025 Honda Prologue",        "date": "2025-11-05"     }, ]  
asked
2 answers
1

Hello 

 

It's an interesting use-case. Have you tried thinking about a more dynamic approach? For example you can model the request entity and the property entity. One request can have many properties. Each property can have multiple other properties (so you can use the self referencing association).  Each property could have all possible data types (all attribute types: long, string, decimal, integer, etc). For this to work you also need a pretty cool way or mechanism to read the request string. Maybe you'll have to write some java code for this to map the string request body to the desired entity model in Mendix.

 

So based on the different response you create this structure of yours which is very dynamic and changing.

 

You can add the configurations dynamically as well. So you can have configuration 1 for the first system, configuration 2 for the second system and so on... 

 

Did you get the idea? I think you should abstract even more so you give yourself the flexibility / option to adapt to the possible differences. 

 

 

answered
1

I guess create an importmapping for each value in 'taskSource' ?

First map the root object (which is always the same). Make sure you map tasksource to an enumeration or similar, then based on this value call the correct import mapping that maps the relevant contentData to a specific object. (EmployeeLeaveData, SAPTravelData and so on ... )

answered