How can I output the entire contents of a nested JSON hash table to a PSO in one line?
$json = @"
{
"outer": "value1",
"outerArray": [
"value2",
"value3"
],
"outerHash": {
"inner": "value4",
"innerArray": [
"value5",
"value6"
],
"innerHash": {
"innermost1": "value7",
"innermost2": "value8",
"innermost3": "value9"
}
}
}
"@
Current behavior: Only one “level” is displayed
$json | ConvertFrom-Json
outer outerArray outerHash
----- ---------- ---------
value1 {value2, value3} @{inner=value4; innerArray=System.Object[]; innerHash=}
Desired behavior: Recursively expand and display all hash/array content
$json | ConvertFrom-Json
outer outerArray outerHash
----- ---------- ---------
value1 {value2, value3} @{inner=value4; innerArray=@(value5, value6); innerHash=@{innermost1=value7; innermost2=value8; innermost3=value9}}
The following seemed to brush on the subject but did not achieve the desired effect: PowerShell Hashtable from JSON PSCustomObject to Hashtable How to output multiple hash tables in Powershell