Skip to content

ConvertTo-Json cmdlet hangs with -Depth 10 for object created using Get-Content #6388

@ikanni

Description

@ikanni

Steps to reproduce

echo "testline1" > test.txt
echo "testline2" >> test.txt

$textContent = Get-Content .\test.txt
$json=ConvertTo-Json -InputObject $textContent -Depth 10 

Expected behavior

ConvertTo-Json should not hang and it should display proper error or exception

Actual behavior

ConvertTo-Json cmdlet hangs

Environment data

> $PSVersionTable
Name                           Value                                                                                        
----                           -----                                                                                        
PSVersion                      5.1.16299.248                                                                                
PSEdition                      Desktop                                                                                      
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                      
BuildVersion                   10.0.16299.248                                                                               
CLRVersion                     4.0.30319.42000                                                                              
WSManStackVersion              3.0                                                                                          
PSRemotingProtocolVersion      2.3                                                                                          
SerializationVersion           1.1.0.1                                                                                      

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions