-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedaffected-very-fewThis issue impacts very few customersThis issue impacts very few customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-json-patchseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Description
Describe the bug
JSON Patch implementation does not work as expected when trying to replace entire object.
Error: The target location specified by path segment '' was not found.
To Reproduce
input:
{
"flightnumber": "3523",
"dep": "YUL",
"dest": "YYZ"
}patch:
[{
"op": "replace",
"path": "",
"value": {
"flightnumber": "111",
"dep": "YYC",
"dest": "YUL"}
}
]output:
{
"flightnumber": "111",
"dep": "YYC",
"dest": "YUL"
}Test runs successful with json8 (https://github.com/sonnyp/JSON8):
https://json8.github.io/patch/demos/apply/
code example:
var flight = new FlightPatchDTO{...};
var patchDoc = new JsonPatchDocument<FlightPatchDTO>();
patchDoc.Replace(x => x, flight);
....Error:
Microsoft.AspNetCore.JsonPatch.Exceptions.JsonPatchException : The target location specified by path segment '' was not found.
at Microsoft.AspNetCore.JsonPatch.Internal.ErrorReporter.<>c.<.cctor>b__1_0(JsonPatchError error)
at Microsoft.AspNetCore.JsonPatch.Adapters.ObjectAdapter.Replace(Operation operation, Object objectToApplyTo)
at Microsoft.AspNetCore.JsonPatch.Operations.Operation`1.Apply(TModel objectToApplyTo, IObjectAdapter adapter)
at Microsoft.AspNetCore.JsonPatch.JsonPatchDocument`1.ApplyTo(TModel objectToApplyTo, IObjectAdapter adapter)
at Microsoft.AspNetCore.JsonPatch.JsonPatchDocument`1.ApplyTo(TModel objectToApplyTo)Further technical details
- ASP.NET Core version: netcoreapp2.2
Metadata
Metadata
Assignees
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedaffected-very-fewThis issue impacts very few customersThis issue impacts very few customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-json-patchseverity-minorThis label is used by an internal toolThis label is used by an internal tool