Mapping json Array of Objects

0
What’s the best way to setup entities and map an array that looks like this: [ { "key1" : "value1", "key2" : "value2", "key3" : "value3", } { "key1" : "value1", "key2" : "value2", "key3" : "value3", } { "key1" : "value1", "key2" : "value2", "key3" : "value3", } ] Lets just say that value1 is unique for each object. I am truly clueless on how to even setup a microflow with the rest call to map this json. This is my attempt     
asked
2 answers
3

Use Mendix's magic:

- Create a JSON-structure:

  • in Project explorer, rightclick and select ‘Other' → ‘JSON structure’
  • Add your json-string to the (btw: you twice need to add a comma between } and { to make your string a valid json)
  • click refresh and save

- Now create an imort mapping:

  • in Project explorer, rightclick and select ‘Other' → ‘Import mapping’
  • select as schema source and select your JSON-structure
  • click ‘Expand all’ and ‘Check all’
  • now click 'Map automatically

- Go in your microflow to your activity RestCall, tab Response and in box ‘Import mapping’ select your mapping. Now you will see an option for 'List’

answered
0

You need 1 entity with 3 attributes in it. 

When you want to export, you can configure it to accept the List of objects for the entity.

Check this link: https://docs.mendix.com/refguide7/export-mapping-action

Key 1 you can make it unique in your domain model with Validation rules

When you want to create these objects using REST POST service, then you can restrict it in your import mapping

Check https://docs.mendix.com/refguide7/import-mappings#1-1-obtaining-an-object

answered