In general I like to use the .NET System.Text.Json
JsonSerializerOptions.WriteIndented = true;
to have nice readable output of Json. However, for objects which have just one property I would like to override the serialization and make it less verbose. So for:
public class SimpleObj
{
public string Text { get; set; }
}
instead of getting :
{
"text": "this is the value"
}
I would like to have:
{ "text": "this is the value" }
If I use JsonSerializerOptions.WriteIndented = false;
then my whole output is less verbose but not what I am looking for.
Is there some kind of extension point or override I can use to achieve this locally for specific objects?