Havunen / SystemTextJsonPatch

SystemTextJsonPatch is a JSON Patch (JsonPatchDocument) RFC 6902 implementation for .NET using System.Text.Json
MIT License
102 stars 12 forks source link

Add snake case test #35

Closed sguryev closed 1 week ago

sguryev commented 2 weeks ago

Here is the test describing true snake case approach using for both path and nested object value values.

{op:"replace", path:"/nested_property", value:"{first_prop:1, second_prop:2}"}

PocoAdapter using snake case handling tries to convert snake_case_name to snake case again and then fails to find the property. image

NET8 has no explicit PascalCase naming policy which is default (null). The condition above returns just a name which is sanka_case_name as it was passed and then fails to find the property.

I have tried to create PascalCase naming policy myself. It works for path and we can find the target property but it leads to fail during value application which is snake_case as well.

Test works for case when path has PascalCase and value has snake_case though: {op:"replace", path:"/NestedProperty", value:"{first_prop:1, second_prop:2}"}

We have truly snake_case API where client uses snake_case for both path and value. And it works with Newtonsoft. What is the best way to make it work with SystemText?

Havunen commented 1 week ago

Yep, this is bug, thanks for the test case will fix!