C# I have a large class with many properties. There are different groups of properties that I sometimes want to update together, but do not want to send the entire object in a request.
Is there an easy way to use JsonSerializer and have it only select properties for serialization with specific attributes?
I would like to do something like JsonSerializer.Serialize(myclass, [CustomNameAttribute]) where it would only pull out UserFirstName and UserLastName. And preferably where I could specify a list of attributes to extract.
public class MyClass{
[CustomNameAttribute]
public string UserFirstName {get;set;}
[CustomNameAttribute]
public string UserLastName {get;set;}
[CustomAddressAttribute]
public string UserAddressLine1 {get;set;}
[CustomAddressAttribute]
public string UserAddressLine2 {get;set;}
...
}