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 and URL encoding #2632

Copy link
Copy link
@stefanstranger

Description

@stefanstranger
Issue body actions

Steps to reproduce

When you use Convertto-Json cmdlet and have an url in one of the properties of your hashtable then the output will show that there took some url encoding place during the conversion.

Expected behavior

I don't want the url encoding to happen. Or at least I want to be able to configure this if needed.

Actual behavior

url encoding is happening.

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.14959.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14959.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Example for testing:

$uri = 'https://www.stranger.nl/thisisstrange?date=2015-04-05&value=foo&this#&%*'

$body = @{

    'url' = $uri

}


$body | convertto-json

[Reflection.Assembly]::LoadFile("C:\Program Files\WindowsPowerShell\Modules\newtonsoft.json\1.0.1.2\libs\Newtonsoft.Json.dll") | out-null

[Newtonsoft.Json.JsonConvert]::SerializeObject($body)

When using the Newtonsoft json class the output is being show as expected.

Output:
{
    "url":  "https://www.stranger.nl/thisisstrange?date=2015-04-05\u0026value=fo
o\u0026this#\u0026%*"
}
{"url":"https://www.stranger.nl/thisisstrange?date=2015-04-05&value=foo&this#&%*
"}
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    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.