Skip to main content
Community site session details
Power Automate - General Discussion
Answered

Converting an input format to another format

Like (0) ShareShare
ReportReport
Posted on 2 Oct 2023 14:15:04 by 72

Hi:

I have the following format in the flow (below) and needed to convert to another format (below - Output). Is this possible?

Format in Flow:

[

  {
    "FileName": "abc.pdf",
    "rpa": "true"
  },
  {
    "FileName": "abc.pdf",
    "robotic process automation": "true"
  },
  {
    "FileName": "abc.pdf",
    "process automation": "true"
  },
  {
    "FileName": "pqr.pdf",
    "rpa": "true"
  },
  {
    "FileName": "pqr.pdf",
    "robotic process automation": "false"
  },
  {
    "FileName": "pqr.pdf",
    "process automation": "true"
  }
]

 

But need to convert to this format (output):

[
  {
    "FileName": "abc.pdf",
    "rpa": "true",
    "robotic process automation": "true",
    "process automation": "true"
  },
  {
    "FileName": "pqr.pdf",
    "rpa": "true",
    "robotic process automation": "false",
    "process automation": "true"
  }
]

  • Verified answer
    SudeepGhatakNZ Profile Picture
    14,381 Most Valuable Professional on 03 Oct 2023 at 01:10:58
    Re: Converting an input format to another format

    @Tak103 ,

     

    You could try converting the following Powershell code into workflow logic.

     

    $json = @"
    [
    {
    "FileName": "abc.pdf",
    "rpa": "true"
    },
    {
    "FileName": "abc.pdf",
    "robotic process automation": "true"
    },
    {
    "FileName": "abc.pdf",
    "process automation": "true"
    },
    {
    "FileName": "pqr.pdf",
    "rpa": "true"
    },
    {
    "FileName": "pqr.pdf",
    "robotic process automation": "false"
    },
    {
    "FileName": "pqr.pdf",
    "process automation": "true"
    }
    ]
    "@

    $data = ConvertFrom-Json $json

    $result = @{}
    $data | ForEach-Object {
    $fileName = $_.FileName
    if (-not $result.ContainsKey($fileName)) {
    $result[$fileName] = @{
    "FileName" = $fileName
    }
    }
    foreach ($key in $_.PSObject.Properties | Where-Object { $_.Name -ne "FileName" }) {
    $result[$fileName][$key.Name] = $key.Value
    }
    }

    $finalResult = $result.Values

    $finalResult | ConvertTo-Json

Helpful resources

Quick Links

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2

Loading complete