I am using Microsoft.AspNetCore.JsonPatch
which I've added via NuGet from here and got stuck when trying to match my properties back on API-side.
Is there any way to preserve the camel-case naming of my properties when serializing/deserializing.
My simplified object:
public class MyObject
{
public string MyCamelCaseProperty { get; set; }
}
When creating a JsonPatchDocument<MyObject>
with the operation Replace
I get the path /mycamelcaseproperty
. But, on API-side I want to make some sort of switch-case by the path
property (without the leading '/') like
var normalizedPath = operation.path.Replace("/", string.Empty)
switch(normalizedPath)
{
case nameof(MyObject.MyCamelCaseProperty):
// do replacement of the MyCamelCaseProperty property
break;
}
The question is: Can the camel-case be preserved or do I have to find another way on how to match the property-names I have to do actions on? Any ideas would be greatly appreciated.