-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Using JsonTypeInfo<object> with JsonSerializerContext configured throws error during serialization steps #87073
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionThe ASP.NET framework derives a Reproduction Stepsusing System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
builder.Services.ConfigureHttpJsonOptions(o => o.SerializerOptions.TypeInfoResolver = JsonContext.Default);
var app = builder.Build();
app.MapGet("/", () => "Hello World!")
.AddEndpointFilter(async (c, n) => {
var r = await n(c);
return Results.Ok(new Todo("Test todo", false));
});
app.Run();
public record Todo(string Name, bool IsCompleted);
[JsonSerializable(typeof(Todo))]
public partial class JsonContext : JsonSerializerContext
{ } Expected behaviorSerialization of the payload to complete successfully. Actual behavior
Regression?No response Known WorkaroundsNo response Configuration
Other informationNo response
|
Description
The ASP.NET framework derives a
JsonTypeInfo<object>
for use in the serialization of filter functions that can return any object type. When used in serialization with a JsonContext, theJsonTypeInfo<object>
throws an unhandled exception to the user.Reproduction Steps
Expected behavior
Serialization of the payload to complete successfully.
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: