I would like to force Newtonsoft.Json's JsonConvert.SerializeObject
to always threat bool values as strings: "true"
and "false"
.
I know that JsonConvert
is a static class, and I should probably write an extension method something like this one:
JsonConvert.DefaultSettings = () => new JsonSerializerSettings {}
but to be honest I have no idea how to do it nor how to implement it into my method:
public static string Serialize(Foo fooData)
{
return JsonConvert.SerializeObject(fooData);
}
I would appreciate any suggestions.