aspnet / JsonPatch

[Archived] JSON PATCH library. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
103 stars 48 forks source link

Property names in Path should use the supplied ContractResolver instead of making it lower case #90

Closed kumbhare closed 7 years ago

kumbhare commented 7 years ago

Given that property names in javascript/json are case sensitive, the serialization of operations to json should honor the supplied ContractResolver instead of always returning in lower case

https://github.com/aspnet/JsonPatch/blob/dev/src/Microsoft.AspNetCore.JsonPatch/JsonPatchDocumentOfT.cs#L718

718         private string GetPath<TProp>(Expression<Func<TModel, TProp>> expr) 
719         { 
720             return "/" + GetPath(expr.Body, true).ToLowerInvariant(); 
721         } 

https://github.com/aspnet/JsonPatch/blob/dev/src/Microsoft.AspNetCore.JsonPatch/JsonPatchDocumentOfT.cs#L776 private string GetPropertyNameFromMemberExpression(MemberExpression memberExpression) uses the contract resolver correctly, but the GetPath function above forces it to lower case.

Neither JSON patch: https://tools.ietf.org/html/rfc6902 nor JSON Pointer: https://tools.ietf.org/html/rfc6901 require it to be lower case, so letting developers control the case through would be a good idea