Steps to reproduce
# Create a nested object
$end = 101
$start = 1
$previous = @{
Depth = $end
Next = $null
}
($end-1)..$start | % {
$current = @{
Depth = $_
Next = $previous
}
$previous = $current
}
$previous | ConvertTo-Json -Depth $end
Expected behavior
PowerShell is able to dynamically check if we are running out of stack, and serialize objects with bigger depths.
Actual behavior
ConvertTo-Json : The maximum depth allowed for serialization is 100.
At line:1 char:13
+ $previous | ConvertTo-Json -Depth $end
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [ConvertTo-Json], InvalidOperationException
+ FullyQualifiedErrorId : ReachedMaximumDepthAllowed,Microsoft.PowerShell.Commands.ConvertToJsonCommand
Environment data
> $PSVersionTable
PS C:\windows\system32> $PSVersionTable
Name Value
---- -----
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.3
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
GitCommitId v6.0.0-alpha.13-139-g152de408523eef294ab8592dd7740dd86c93313f
CLRVersion
PSVersion 6.0.0-alpha
PSEdition Core
BuildVersion 3.0.0.0
Steps to reproduce
Expected behavior
PowerShell is able to dynamically check if we are running out of stack, and serialize objects with bigger depths.
Actual behavior
Environment data