Azure Logic Apps - Map Json to Json with Liquid flatten array

781 views Asked by At

Any help would be much appreciated. What I am trying to achieve is to request a record from Dynamics 365(cloud) to an on-premise system (exposed by mulesoft) I have decided to use Azure logic apps to do the integration and to use Liquid to do the mapping, however I am battling to flatten the array with liquid, I'm getting a JSON payload from the on-premise system which I need to transform readily to load into dynamics 365, what I am getting is something like the following:

{
    "person": {
        "firstname": " Fred",
        "surname" : "Smith",
        "age": 27,
        "phoneno":"123456789",
        "addresses": [
            {
                "address": {
                    "AddressLine1":"1 milky way",
                    "AddressLine2":"galaxy cresent",
                    "city": "tempest",
                    "state": "Idiho",
                    "postcode": "12345"             
                }
            },
            {
                "address": {
                    "AddressLine1":"52 Saturn Drive",
                    "AddressLine2":"Wharfridge",
                    "city": "tempest",
                    "state": "Idiho",
                    "postcode": "12345"             
                }
            }   
        ]
    }
}

and what I need is to flatten the array into the root node like this:

{
    "person": {
        "firstname": " Fred",
        "surname" : "Smith",
        "age": 27,
        "phoneno":"123456789",
        "addr1_AddressLine1":"1 milky way",
        "addr1_AddressLine2":"galaxy cresent",
        "addr1_city": "tempest",
        "addr1_state": "Idiho",
        "addr1_postcode": "12345",          
        "addr2_AddressLine1":"52 Saturn Drive",
        "addr2_AddressLine2":"Wharfridge",
        "addr2_city": "tempest",
        "addr2_state": "Idiho",
        "addr2_postcode": "12345"
    }
}

If there any other solutions\ideas, i am all ears.

Thanks in advance for your help Paul

1

There are 1 answers

0
Paul On

So i found a solution or rather a work around, for some reason the liquid connector in logic apps does not support the "increment" tag, this was causing my issue. i was able to evaluate a property form the input json to decide where my fields would reside. but thanks for