Код: Выделить всё
using System.Text.Json;
JsonSerializerOptions options = new()
{
//Converters = { new JC.SecretAttributeConverterFactory() },
WriteIndented = true
};
C c = new() { Overt = "Overt", Secret = "Secret" };
var json = JsonSerializer.Serialize(c, options);
Console.WriteLine(json);
public class SecretAttribute : Attribute { }
class C
{
public required string Overt { get; set; }
[Secret]
public string? Secret { get; set; }
public List Collection { get; set; } = ["one", "two", "three"];
}
< /code>
Выходы < /p>
{
"Overt": "Overt",
"Collection": ["one", "two", "three"]
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... properties