Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ConvertTo-Json string escaped handling differs between PS and PSCore #7693

Copy link
Copy link
@PlagueHO

Description

@PlagueHO
Issue body actions

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:

{
  "abc": "'def'"
}

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.

image

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.