Implement case sensitive property matching #2709
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves #815, by implementing a new serializer option, named
PropertyCaseSensitivityHandling
:To preserve continuity with prior implementations, default is set to
CaseInsensitive
.With the new behaviour provided by
CaseSensitive
, we can now have differentiation and validation for casing, which is required by several API specs (Binance & xAPI, to name a few examples).As this behaviour has an extremely lightweight implementation (only one extra check on each Property matching), it does what it says on the tin, and only that.
Most of the matching with convention-following PascalCase C# properties will fail if you don't add
[JsonProperty("name")]
to each property, or write some esoteric conversion between JSON standard camelCase (or whichever casing is used) and C# Properties.A few footnotes...
This PR was inspired by the stale #601, where I factually stripped the Casing implementation to form my own.
Furthermore, as this is my first ever PR to Newtonsoft.Json (hello guys!), I might've inadvertently broken a few long-standing conventions along the way, so any feedback will be most appreciated.