Steps to reproduce
On PowerShell Core 6.0.4
ConvertTo-Json -InputObject @{ 'abc' = "'def'" }
Expected behavior
Windows PowerShell 5.x returns:
{
"abc": "\u0027def\u0027"
}
Actual behavior
PowerShell Core 6.0.4 returns:
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.4
PSEdition Core
GitCommitId v6.0.4
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This would appear to be because the StringEscapeHandling setting is set to Default in
|
JsonSerializerSettings jsonSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.None, MaxDepth = 1024 }; |
If the StringEscapeHandling setting is set to [Newtonsoft.Json.StringEscapeHandling]::EscapeHtml then the JSON string that is generated matches what is returned by Windows PowerShell.

Steps to reproduce
On PowerShell Core 6.0.4
Expected behavior
Windows PowerShell 5.x returns:
Actual behavior
PowerShell Core 6.0.4 returns:
Environment data
This would appear to be because the
StringEscapeHandlingsetting is set toDefaultinPowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs
Line 128 in 6671757
If the
StringEscapeHandlingsetting is set to[Newtonsoft.Json.StringEscapeHandling]::EscapeHtmlthen the JSON string that is generated matches what is returned by Windows PowerShell.