I have a class that I referenced from an internal nuget package
public class Person
{
public string Name { get; set;}
public int Age{ get; set;}
}
and I am using System.Text.Json to serialize the instantiated message.
When I initialized an instance of the class, say for example
Person p = new Person() {Name = "Abraham"};
and serialized it, the resulting string still includes the Age property.
Person {
"Name": "Abraham",
"Age": 0
}
May I know how will I be able to serialize an instance of a class with only the initialized properties included.