This sample uses a Argon.JsonConverter
to customize how JSON is serialized.
var stringComparisons = new List<StringComparison>
{
StringComparison.CurrentCulture,
StringComparison.Ordinal
};
var jsonWithoutConverter = JsonConvert.SerializeObject(stringComparisons);
Console.WriteLine(jsonWithoutConverter);
// [0,4]
var jsonWithConverter = JsonConvert.SerializeObject(stringComparisons, new StringEnumConverter());
Console.WriteLine(jsonWithConverter);
// ["CurrentCulture","Ordinal"]
var newStringComparsons = JsonConvert.DeserializeObject<List<StringComparison>>(
jsonWithConverter,
new StringEnumConverter());
Console.WriteLine(string.Join(", ", newStringComparsons.Select(_ => _.ToString()).ToArray()));
// CurrentCulture, Ordinal