Unexpected Serialization Behavior with Newtonsoft.Json in .NET 6 and Nullable Reference Types
I'm experimenting with Quick question that's been bugging me - I'm working with an scenario when using Newtonsoft.Json to serialize an object that includes nullable properties in .NET 6. Specifically, I have a class with a property defined as `string?` and I expect it to serialize as `null` when the property is not set. However, I see that itβs being serialized as an empty string instead. Hereβs a simplified version of my class: ```csharp public class UserProfile { public string? Name { get; set; } public string? Email { get; set; } } ``` When I create an instance of `UserProfile` without initializing `Name` and then serialize it: ```csharp var userProfile = new UserProfile { Email = "user@example.com" }; var json = JsonConvert.SerializeObject(userProfile); ``` The output I get is: ```json {"Name":"","Email":"user@example.com"} ``` My expectation was for it to serialize like this: ```json {"Name":null,"Email":"user@example.com"} ``` Iβve tried setting `NullValueHandling` to `Include`, but that didn't change the behavior. I also checked if any custom converters could be influencing this, but I haven't found anything relevant. I want to ensure that if the property is not set, it should be explicitly serialized as `null`. Could someone shed light on why this is happening and how I can achieve the desired serialization behavior? For context: I'm using C# on Linux. Any help would be greatly appreciated!