A bit of noob in this topic, so would appreciate any ideas. I am trying to parse output of invoke-webrequest from API which I struggle to into usable data to feed into MS PowerAutomate. Unfortunately, the structure of data which is returned from API in "Content" is a unnecessary overcomplicated with multiple layers, ie:
'name': 'blabla',
'date': '01/01/2021',
'**additionaldata**': {
'newValue': 'etcetc',
'oldValue': 'xyzxyz',
'**extension**': "@{IsTrue=True; IsFalse=False; Name=AAA; LastDate=01/02/20}
'otherData': 'cbacba'
}
'someInfo': 'Abcd',
'otherInfo': 'Efgh'
So for now I am just outputting:
$Output = Invoke-WebRequest -Method GET -Headers $headers - -Uri "https://api.url.com" | Select -ExpandProperty Content | ConvertFrom-Json
$Output | ConvertTo-Json | Out-File "..\Data.json" -encoding UTF8 -Append
to keep some from top level and some from these nested ones. For example to get level 3 (extension) I can use nested Select to get values from there, i.e :
Select -ExpandProperty additionalData | Select -ExpandProperty extension | Select IsTrue, IsFalse, Name, LastDate
But this way I can't get to output top level or parameters from additionaldata level for example. What wouldbe best way to have an otput like to combine values from all these, i.e (since it would be seriously easier to feed that into PowerAutomate without any extra actions to parse it further):
{
'name': 'blabla',
'IsTrue': true,
'IsFalse': false,
'Name': 'Abc',
'LastDate': '01/02/2021',
'newValue': 'etcetc',
'oldValue': 'xyzxyz',
},
Hope it makes sense, would be more than happy to clarify if this is a messy explanation.