-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core modulecmdlets in the Microsoft.PowerShell.Core moduleWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Include a comment in json, one example can be seen here:
'{
// A Json comment
"string": "test"
}' | Test-Json
In previous versions of PS this worked as expected.
Expected behavior
PS> '{
// A Json comment
"string": "test"
}' | Test-Json
TrueActual behavior
PS> '{
// A Json comment
"string": "test"
}' | Test-Json
Test-Json: Cannot parse the JSONError details
Exception :
Type : System.Exception
Message : Cannot parse the JSON.
InnerException :
Type : System.Text.Json.JsonReaderException
LineNumber : 1
BytePositionInLine : 4
Message : '/' is invalid after a value. Expected either ',', '}', or ']'. LineNumber: 1 | BytePositionInLine: 4.
TargetSite :
Name : ThrowJsonReaderException
DeclaringType : System.Text.Json.ThrowHelper, System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
MemberType : Method
Module : System.Text.Json.dll
Source : System.Text.Json
HResult : -2146233088
StackTrace :
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker)
at System.Text.Json.Utf8JsonReader.ConsumeNextTokenOrRollback(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)
at System.Text.Json.JsonDocument.ParseUnrented(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, JsonTokenType tokenType)
at System.Text.Json.JsonDocument.ParseValue(ReadOnlyMemory`1 json, JsonDocumentOptions options)
at System.Text.Json.Nodes.JsonNode.Parse(String json, Nullable`1 nodeOptions, JsonDocumentOptions documentOptions)
at Microsoft.PowerShell.Commands.TestJsonCommand.ProcessRecord()
HResult : -2146233088
TargetObject : {
// A Json comment
"string": "test"
}
CategoryInfo : InvalidData: ({
// A Json com… "string": "test"
}:String) [Test-Json], Exception
FullyQualifiedErrorId : InvalidJson,Microsoft.PowerShell.Commands.TestJsonCommand
InvocationInfo :
MyCommand : Test-Json
ScriptLineNumber : 4
OffsetInLine : 6
HistoryId : 4
Line : }' | Test-Json
Statement : Test-Json
PositionMessage : At line:4 char:6
+ }' | Test-Json
+ ~~~~~~~~~
InvocationName : Test-Json
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :Environment data
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
hoobi-nintex, mklement0 and IISResetMehoobi-nintex
Metadata
Metadata
Assignees
Labels
In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core modulecmdlets in the Microsoft.PowerShell.Core moduleWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation

