C# 9.0 Record Type Serialization implementing Newtonsoft.Json in Web API
I recently switched to I'm relatively new to this, so bear with me. I'm working with issues when trying to serialize a record type in C# 9.0 using Newtonsoft.Json in my ASP.NET Core Web API application. My record looks like this: ```csharp public record Person(string Name, int Age); ``` When I try to return a list of `Person` records from my API endpoint, I receive the following behavior: ``` JsonSerializationException: Could not create an instance of type 'Person'. Type is an interface or abstract class. ``` Here is the relevant part of my controller: ```csharp [ApiController] [Route("api/[controller]")] public class PeopleController : ControllerBase { [HttpGet] public ActionResult<IEnumerable<Person>> GetPeople() { var people = new List<Person> { new Person("Alice", 30), new Person("Bob", 25) }; return Ok(people); } } ``` I've confirmed that I have the latest version of Newtonsoft.Json installed (13.0.1) and that my project is targeting .NET 5. Also, I've tried adding the following settings to my `Startup.cs`: ```csharp services.AddControllers().AddNewtonsoftJson(); ``` However, the behavior continues. I've also checked to ensure that the `JsonSerializerSettings` are not being overridden elsewhere in my application. Is there something specific I need to do to enable proper serialization for record types using Newtonsoft.Json? Any help would be greatly appreciated! For context: I'm using C# on Ubuntu. How would you solve this? Thanks in advance! For reference, this is a production service. Thanks for any help you can provide!