I am trying to find a way to manipulate the output obtained from the API request.
The output is similar to this:
[
{
"Date": "19/5/2022",
"ProductId": "0001",
"ProductName": "Fizzy Drink",
"Cost": "2.32",
"Currency": "USD",
},
{
"Date": "16/5/2022",
"ProductId": "0002",
"ProductName": "Dark Chocolate",
"Cost": "6.52",
"Currency": "USD",
},
{
"Date": "10/5/2022",
"ProductId": "0003",
"ProductName": "Snacks",
"Cost": "4.2",
"Currency": "USD",
}
]
How can manipulate this type of data?
My goal is to obtain something like this:
- Date 19/5/2022
- ProductID 0001
- ProductName Fizzy Drink
- Cost 2.32
- Currency USD
- Date 16/5/2022
- ProductID 0002
- ProductName Dark Chocolate
- Cost 6.52
- Currency USD
I've tried something like this: (without success)
foreach($GetInfo in $IDInfo)
{
$ID = $GetInfo.data.Date
$Name = $GetInfo.data.ProductId
Write-Host $ID
Write-Host $Name
}
But every time I got, the date on one line, ProductID on the second line, and ProductName on the third line.
like:
19/5/2022 16/5/2022 16/5/2022
0001 0002 0003
Fizzy Drink Dark Chocolate Snacks