Convert data from service to required domain model - Mendix Forum

Convert data from service to required domain model

0

I am consuming a rest service which provide the following JSON data:

{
    "metadata": {
        "link": "",
        "modifiedTime": "7"
    },
    "product": [
        {
            "name": "p1",
            "description": "",
            "properties": {
                "weight": "200",
				"price": "100"
            },
            "batch": "B"
        }
    ],
    "store": [
        {
            "name": "Store1",  
            "address": "Addr1",
            "properties": {},
            "location": "A"
        }
    ],
    "allRelations": {
        "productStoreRelations": [
            {
                "attributes": {
                    "name": "Store1",
                    "location": "A"
                },
                "availableProducts": [
                    {
                        "attributes": {
                            "name": "p1",
                            "batch": "B"
                        },
                        "properties": {}
                    }
                ]
            }
        ]
    }
}

To consume it, I have added an import mapping :

 

In UI, I want a representation where I need to show what all products are available in the particular store alongwith the price:

 

How can I map the domain model (import_mapping) to the one required in the UI ? 

asked
1 answers
1

After receiving your data, in your microflow you’ll probably end up with your Root object thats on the top of your import mapping. You can retrieve the rest of the object that you’ve received form this object, and convert them to your liking to create the objects as required in your own domain model. You can check the Mendix reference guide for more information on this topic, or take a look at the Academy learnings that deal with this subject.

Good luck!

answered