Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialize a JSON string with the property name had no quotes #74055

Closed
WeihanLi opened this issue Aug 17, 2022 · 3 comments
Closed

Deserialize a JSON string with the property name had no quotes #74055

WeihanLi opened this issue Aug 17, 2022 · 3 comments

Comments

@WeihanLi
Copy link
Contributor

WeihanLi commented Aug 17, 2022

Description

When I try to deserialize a JSON string with the property name had no ", it would throw an exception now, while it works with Newtonsoft.Json

Not sure if it's a problem, it may not a standard JSON

json sample:

{ CustomerId: "2929064f-1a22-4ece-947f-00eed7efed35"}

Reproduction Steps

Deserialize the previous JSON with system text json

System.Text.Json.JsonSerializer.Deserialize<JsonObject>(json);

Expected behavior

Success with JsonObject returned

Actual behavior

Got an exception likes follows:

System.Text.Json.JsonException: 
'C' is an invalid start of a property name. Expected a '"'. LineNumber: 0 | BytePositionInLine: 2.

Regression?

No response

Known Workarounds

No response

Configuration

.NET 6

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 17, 2022
@ghost
Copy link

ghost commented Aug 17, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When I try to deserialize a JSON string with the property name had no ", it would throw an exception now, while it works with Newtonsoft.Json

json sample:

{ CustomerId: "2929064f-1a22-4ece-947f-00eed7efed35"}

Reproduction Steps

Deserialize the previous JSON with system text json

System.Text.Json.JsonSerializer.Deserialize<JsonObject>(json);

Expected behavior

Success with JsonObject returned

Actual behavior

Got an exception likes follows:

System.Text.Json.JsonException: 
'C' is an invalid start of a property name. Expected a '"'. LineNumber: 0 | BytePositionInLine: 2.

Regression?

No response

Known Workarounds

No response

Configuration

.NET 6

Other information

No response

Author: WeihanLi
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@WeihanLi WeihanLi changed the title Not sure if it's a problem Deserialize a JSON string with the property name had no quotes Aug 17, 2022
@WeihanLi
Copy link
Contributor Author

relates to #32291

@eiriktsarpalis
Copy link
Member

Property names lacking quotes is not valid JSON, but we might consider offering an optional flag that enables support. Closing as duplicate of #32291.

@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 17, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants