Skip to content

Emit warning if ConvertTo-Json exceeds -Depth value #7172

@sdwheeler

Description

@sdwheeler

Summary of the new document or enhancement

Add to notes section

Description of what changed

When using ConvertTo-Json, the default -Depth value is 2 to avoid recursion for objects like Services on Windows. Users who do not set a deep enough depth may be losing data they may not be aware of as they expected full fidelity of the object to be serialized to JSON. The change agreed by @PowerShell/powershell-committee is to emit a warning message once the depth is exceeded. The warning is only emitted once per object serialized, but note that arrays are treated as a single object and not unrolled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-utilityArea - Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions