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

System.Text.Json: [JsonExtensionData] on a property of type JsonObject generates invalid JSON when serializing #60806

Closed
nextdracool opened this issue Oct 24, 2021 · 3 comments
Labels
area-System.Text.Json untriaged New issue has not been triaged by the area owner

Comments

@nextdracool
Copy link

Description

Invalid JSON is generated when serializing an object when the [JsonExtensionData] attribute is applied to a property of type JsonObject.

Reproduction Steps

see repository: https://github.com/nextdracool/JsonExtensionDataInvalidJsonWithJsonObject

Expected behavior

The JsonObject keys should be added to the serialized JSON object: {"Fixed":0,"foo":"bar"}

Actual behavior

Invalid JSON is generated: {"Fixed":0,{"foo":"bar"}}

Regression?

No response

Known Workarounds

No response

Configuration

.NET 6 RC2,
System.Text.Json 6.0.21.48005

Other information

Possibly related to #60560

This feature was specifically mentioned in Preview 4.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Oct 24, 2021
@ghost
Copy link

ghost commented Oct 24, 2021

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

Issue Details

Description

Invalid JSON is generated when serializing an object when the [JsonExtensionData] attribute is applied to a property of type JsonObject.

Reproduction Steps

see repository: https://github.com/nextdracool/JsonExtensionDataInvalidJsonWithJsonObject

Expected behavior

The JsonObject keys should be added to the serialized JSON object: {"Fixed":0,"foo":"bar"}

Actual behavior

Invalid JSON is generated: {"Fixed":0,{"foo":"bar"}}

Regression?

No response

Known Workarounds

No response

Configuration

.NET 6 RC2,
System.Text.Json 6.0.21.48005

Other information

Possibly related to #60560

This feature was specifically mentioned in Preview 4.

Author: nextdracool
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@eiriktsarpalis
Copy link
Member

This is caused by the presence of a custom converter for JsonObject, so I believe this is a duplicate of #60560.

@nextdracool please consider upvoting and contributing to the other issue so we can prioritize accordingly.

@nextdracool
Copy link
Author

Seems like that's the case. The custom converter is apparently implicitly present even when clearing all converters from the JsonSerializerOptions. There seems to be no way to remove it completely.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants