neuecc / Utf8Json

Definitely Fastest and Zero Allocation JSON Serializer for C#(NET, .NET Core, Unity, Xamarin).
MIT License
2.36k stars 267 forks source link

SnakeCase Json and PascalCase C# #119

Open normj opened 5 years ago

normj commented 5 years ago

I'm from the AWS .NET team that does a lot of the .NET Lambda tooling. I wanted to compare this library with the JSON.NET one we support. I saw you had an example code in your README but I can't get it to work because the JSON AWS services send uses snake case which doesn't match the Pascal Case all of the .NET properties are using when deserializing.

Am I missing a setting somewhere to make that work?

DSilence commented 5 years ago

You can specify the case using resolver passed to deserialization method or specified as default. E.g.:

JsonSerializer.Deserialize<T>(Data, StandardResolver.ExcludeNullSnakeCase);

or you can specify default resolver to use JsonSerializer.SetDefaultResolver(StandardResolver.ExcludeNullSnakeCase);

You can read more about resolvers in this portion of README https://github.com/neuecc/Utf8Json#resolver