-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
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 0Expected behavior
[PSCustomObject] @{
Test = 1
Test2 = 2
Test3 = [PSCustomObject] @{
IdontWantThat = 1
}
} | ConvertTo-Json -Depth 0Should 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
SeeminglyScience, iRon7, mklement0 and dennisl68-castra
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module