My aws cli returns multiline array with nested hash, I am not able to parse output to get appropriate values from it
>Write-Host $a
[
[
[
{
"VolumeID": "vol-fxxxxxx"
}
]
]
]
If I do $a[0], it returns first line i.e. "[" same with incremental indexs. How I can parse this array and get the volumeID from it ? Thanks
Additional details :
Thanks for your valuable answers. Here is the class name of the above object :
> $a.getType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
> $a | Where-Object ($_ -like "*Volume*")
> $a | ConvertFrom-Json
ConvertFrom-Json : Invalid JSON primitive:
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData.
At line:1 char:6
+ $a | ConvertFrom-Json
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand
Hi Martin Brandl, TessellatingHeckler I have updated with your question, could you please help me out on the same. Thanks
$a.GetType()$ais just a multiline string, and$a[0]returns[because that's the first character?