dotnet / dotnet/aspnetcore

JsonPath for private properties

Open
#51,514 5 comments 1 reaction 0 assignees View on GitHub
area-mvc feature-json-patch
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

I created class with private property setter (DDD style) and use it for JsonPath. I received error "The property at path 'Name' could not be updated."
```
public class Product
{
public string Name { get; private set; }
}

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
[HttpPatch]
public void Patch([FromBody] JsonPatchDocument p)
{
var prod = new Product();
p.ApplyTo(prod);
}
}

```

### Describe the solution you'd like

I'd like to update property value when property setter is private. DDD approach and RichModel is very popular now, a lot of teams creates encapsulated model classes with private setters. Other JsonPath implementations allows to initialize properties with private setters.
PocoAdapter class can be fixed

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.