DevBetterCom / DevBetterCom/DevBetter.JsonExtensions
Fails to deserialize when changing naming policy.
- Dominant language
- C#
- Stars
- 4
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
The naming policy seems to be ignored.
Changing the PropertyNamingPolicy to CamelCase has no effect, it does not throw an exception and returns the object with its defaults.
For example, this test fails:
```csharp
[Fact]
public void SerializeProperlyWhenNamingPolicyIsNotTheDefault()
{
var jsonString = @"{""id"":3, ""title"": ""Title""}";
var deserializeOptions = new JsonSerializerOptions()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
deserializeOptions.SetMissingMemberHandling(MissingMemberHandling.Error);
var response = JsonSerializer.Deserialize(jsonString, deserializeOptions);
response.Title.ShouldBe("Title");
}
```
But, it works if I remove the line:
```csharp
deserializeOptions.SetMissingMemberHandling(MissingMemberHandling.Error);
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.