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"
}
]
@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
Tomac
986
Moderator
stampcoin
699
Super User 2025 Season 2
Riyaz_riz11
577
Super User 2025 Season 2