8000 In ConvertTo-Json the max allowed depth is 100. However, we should add code to dynamically check if we are running out of stack, and serialize objects with bigger depths. · Issue #3181 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

In ConvertTo-Json the max allowed depth is 100. However, we should add code to dynamically check if we are running out of stack, and serialize objects with bigger depths. #3181

@Francisco-Gamino

Description

@Francisco-Gamino

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
PSComp
6B11
atibleVersions           {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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0