Logic Apps Json Manipulation

Biju Mathew 476 Reputation points
2023-03-24T07:18:21.42+00:00

Hi,

Good day.

We have an input JSON that is of the following schema:

{
  "result": [
    {
      "table": "test1",
      "field": "completed_on",
      "sys_id": "7d6a0a84dc0",
      "created_by": "user1"
    },
    {
      "table": "test2",
      "field": "statew",
      "sys_id": "a0a84dc0",
      "created_by": "user2"
    }
  ]
}

This needs to be transformed to a array of objects as below:

[{"table": "test1","field": "completed_on","sys_id": "7d6a0a84dc0","created_by": "user1"},

{"table": "test2","field": "statew","sys_id": "a0a84dc0","created_by": "user2"}

]

As you can see, we removed the "result" element from the input.

Any way I could achieve this transformation in Logic Apps please?

thanks

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,873 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Bruno Lucas 4,411 Reputation points MVP
    2023-03-26T02:39:51.85+00:00

    Hi

    Did you try Json Parser?

    Add a "parse JSON"

    Add the json output to the content (#1) field

    Click on "use sample payload to generate schema" and paste the json sample in there

    User's image

    Parse Json will create the array as you suggested above. after that depend on how you want to access it. to loop through it you can do like this:

    User's image

    I used a set variable only to show that the array is under the "result" object coming from the "Parse Json"

    User's image

    this is the history view:

    User's image


  2. MayankBargali-MSFT 68,746 Reputation points
    2023-03-29T11:58:40.3966667+00:00

    @Biju Mathew Thanks for reaching out. As per the screenshot that you have shared, I can see the input is the octet stream, so you need to convert the convert the $content output of your blob connector to base64String in your ParseJSON action

    User's image

    For your reference sharing the screenshot. Please update the action name as per your workflow.

    User's image

    Feel free to get back to me if you need any assistance.

    Please accept as "Yes" if the answer is helpful so that it can help others in the community. If you need any help/clarification/concerns/follow up questions, then please click on "Add Comment" on my answer and provide more details.

    0 comments No comments

  3. Biju Mathew 476 Reputation points
    2023-03-31T06:54:23.7633333+00:00

    Thanks @MayankBargali-MSFT , @Bruno Lucas for your continued assistance. Sorry about the delay in response.

    I have tried the approaches you mentioned but i still get the issue. Please see below.

    User's image

    User's image

    User's image

    This is how Compose 2 inputs property is configured

    User's image

    base64ToString(body('Read_blob_content')?['$content'])

    Please I am not sure what else to try . I must point out that our Logic Apps instance is a Standard, App Service Environment model.

    Please any other tips to try.

    Thanks

    0 comments No comments