There seems to be an oversight of what ConvertTo-JSON allows when it comes to nesting. Since the default value is 2 (not 0) it's impossible to set it to 0, as minimal value is 1.
Steps to reproduce
[PSCustomObject] @{
Test = 1
Test2 = 2
Test3 = [PSCustomObject] @{
IdontWantThat = 1
}
} | ConvertTo-Json -Depth 0
Expected behavior
[PSCustomObject] @{
Test = 1
Test2 = 2
Test3 = [PSCustomObject] @{
IdontWantThat = 1
}
} | ConvertTo-Json -Depth 0
Should be:
{
"Test":"1",
"Test2":"2",
"Test3":"@{IDontWantThat=1}"}
or similar
Actual behavior
[PSCustomObject] @{
Test = 1
Test2 = 2
Test3 = [PSCustomObject] @{
IdontWantThat = 1
}
} | ConvertTo-Json -Depth 0
ConvertTo-Json : Cannot validate argument on parameter 'Depth'. The 0 argument is less than the minimum allowed range of 1. Supply an argument that is greater than or equal to 1 and then try the command again.
Environment data
There seems to be an oversight of what ConvertTo-JSON allows when it comes to nesting. Since the default value is 2 (not 0) it's impossible to set it to 0, as minimal value is 1.
Steps to reproduce
Expected behavior
Should be:
or similar
Actual behavior
Environment data