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

ConvertFrom-Json does not respect -ErrorAction #2860

Copy link
Copy link
@alastairs

Description

@alastairs
Issue body actions

Steps to reproduce

Run the following expressions:

"some invalid JSON string" | ConvertFrom-Json -ErrorAction Ignore
"some invalid JSON string" | ConvertFrom-Json -ErrorAction SilentlyContinue

Expected behavior

Both expressions write no error to the console, and return either $null or the empty string.

Actual behavior

The expressions write an error to the console and throw the following exception:

ConvertFrom-Json : Invalid JSON primitive: some invalid JSON string.
At line:1 char:12
+ "some invalid JSON string" | ConvertFrom-Json -ErrorAction Ignore
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14393.206
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.206
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
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 decisionResolution-By DesignThe reported behavior is by design.The reported behavior is by design.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

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.