❔ How does ASP.NET deserialize JSON to records?
This isn't specifically related to ASP.NET, but still wondering. If I have an endpoint like this then ASP.NET has no problem deserializing the body into the record. But... how does it do that? Just using System.Text.Json it doesn't appear like you can (or I'm doing something wrong), and plus, the properties that records generate don't have setters. How does this work?
2 Replies
I know records generate essentially get-only auto-properties for all the parameters of its primary constructor, which means that each of those properties also have a backing fields. So does the JSON deserialization somehow link properties to their corresponding backing fields and set the fields instead?
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.