-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.This issue needs the attention of a contributor, typically because the OP has provided an update.Needs: ReproIndicates that the team needs a repro project to continue the investigation on this issueIndicates that the team needs a repro project to continue the investigation on this issuearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Milestone
Description
Description
Serializing an ulong to JSON within asp.net core loses precision. Stumbled over this while upgrading an older project from traditional ASPnet to .net core 8.
Reproduction Steps
Using .net 8 and System.Text.Json 8.0.0.
public class Test
{
public ulong Key { get; set; }
}
Exposing data via minimal API
app.MapGet("/api/test", async (HttpContext context) =>
{
return new Test() { Key = 2121241830635120343 };
});
The result in the browser is the following:
{
"Key": 2121241830635120400
}
Expected behavior
{
"Key": 2121241830635120343
}
Actual behavior
{
"Key": 2121241830635120400
}
Regression?
No response
Known Workarounds
For the moment I have written a custom JsonConverter which calls ToString for the ulong myself.
Configuration
.net 8, running x64 (emulated on win dev kit arm64) on Windows 11.
System.Text.Json 8.0.0
Other information
No response
Silverviql, grimurd and IngweLand
Metadata
Metadata
Assignees
Labels
Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.This issue needs the attention of a contributor, typically because the OP has provided an update.Needs: ReproIndicates that the team needs a repro project to continue the investigation on this issueIndicates that the team needs a repro project to continue the investigation on this issuearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc