You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using [JsonExtensionData], I expect roundtrip serialization to work, but when the property is typed as JsonObject, the serialized output is malformed.
I expect JsonObject to be a possible type because the exception thrown when using a different type is:
System.InvalidOperationException: The extension data property 'System.Object.Extensions' is invalid.
It must implement 'IDictionary<string, JsonElement>' or 'IDictionary<string, object>', or be 'JsonObject'.
Reproduction Steps
Executing the following code produces the malformed output: {"a":2,{"b":true,"c":"something"}}
Description
When using
[JsonExtensionData]
, I expect roundtrip serialization to work, but when the property is typed asJsonObject
, the serialized output is malformed.I expect
JsonObject
to be a possible type because the exception thrown when using a different type is:Reproduction Steps
Executing the following code produces the malformed output:
{"a":2,{"b":true,"c":"something"}}
https://dotnetfiddle.net/DbSzlH
Expected behavior
The serialized value should be the same as the original:
{"a":2,"b":true,"c":"something"}
Actual behavior
The serialized value is malformed:
{"a":2,{"b":true,"c":"something"}}
Regression?
No response
Known Workarounds
Using 'Dictionary<string, JsonElement>' or 'Dictionary<string, object>' works, only JsonObject fails.
Configuration
.NET 8 and .NET 9
Reproduced in my windows computer, in a linux environment and in dotnetfiddle.
Other information
This ticket #60560 is the same, talking about a custom converter, but there's no custom converter involved here.
The text was updated successfully, but these errors were encountered: