This is the dummy.json file
{
"key1":"value1",
"key2":"value2"
}
I'm reading the contents of this file to a variable and outputting them
C:> $obj = Get-Content .\dummy.json
C:> $obj
{
"key1":"value1",
"key2":"value2"
}
C:> Write-Host "$obj"
{ "key1":"value1", "key2":"value2" }
I know that Get-Content doesn't preserve the line breaks and joins it by " ". Powershell keep text formatting when reading in a file
But why is there an inconsistency in the above 2 outputs ? I guess Write-Host
is doing its job correctly. Or am I wrong ?