This extension for Utf8Json library. Utf8Json is fast serialization library with good performance but without some functions (for example case insensitive enums).
EnumCaseIgnore resolver is slightly modified and upgraded standard Utf8Json EnumResolver with the the closest to original perfomance (see benchmarks). It uses same hash function to quickly compare bytes (see FarmHash.cs file, copied from original repository, because it's internal there). Can serialize enums values with origin, camelcase, snakecase options. Can deserialize case insensetive enums values.
EnumCaseIgnore Serialization benckmark
EnumCaseIgnore Deserialization benchmark
- Install NuGet package
Install-Package Utf8Json.Extensions
- Create Utf8Json CompositeResolver with EnumCaseIgnoreResolver (override default EnumResolver)
var obj = new SimpleObject() { Id = Guid.NewGuid(), Name = "TestObject" };
var resolver = CompositeResolver.Create(EnumCaseIgnoreResolver.Default, tandardResolver.Default);
var result = JsonSerializer.ToJsonString(obj, resolver);
MIT