There is a book class with public and private properties:
public class Book
{
private int ID { get; set; } = -1;
private string? BaseName { get; set; } = null;
public string? Title { get; private set; } = null;
public string? Author { get; set; } = null;
}
I need the ability to serialize both including private properties and without them.
JsonSerializerOptions
does not support this option.
Other serializers are model-bound: above each model property, I need to specify whether the property should be serialized but I need to manage this after the program has run.
The only solution I see is converting one model with private properties to another that makes these properties public, but this way I create a lot of duplicate classes.