Arnold Robert Turdean created JOHNZON-312: ---------------------------------------------
Summary: JsonPatch's add operation updates unexpected fields Key: JOHNZON-312 URL: https://issues.apache.org/jira/browse/JOHNZON-312 Project: Johnzon Issue Type: Bug Components: Core Affects Versions: 1.2.5, 1.2.3 Reporter: Arnold Robert Turdean Fix For: 1.2.6 Recently we found an important bug with the Johnzon framework. It's easy to reproduce and the fix seems important. The add operation is not working 100% well for nested objects. (in my example for a map which contains a list in the value) Example: Data: {code:java} { ... "caseDiscussionDailySchedule":{ "schedule":{ "TUESDAY":[ { "start":"07:00+03:00", "end":"08:00+03:00" } ], "MONDAY":[ { "start":"07:00+03:00", "end":"08:00+03:00" } ] } }, ... } {code} Operation: {code:java} [ {"op": "replace", "path": "/caseDiscussionDailySchedule/schedule/MONDAY/0/start", "value": null} ] {code} I expect that the result should be this: {code:java} { ... "caseDiscussionDailySchedule":{ "schedule":{ "TUESDAY":[ { "start":null, <--------------------- "end":"08:00+03:00" } ], "MONDAY":[ { "start":"07:00+03:00", "end":"08:00+03:00" } ] } }, ... } {code} , but because of the mentioned bug the result is: {code:java} { ... "caseDiscussionDailySchedule":{ "schedule":{ "TUESDAY":[ { "start":null, <--------------------- "end":"08:00+03:00" } ], "MONDAY":[ { "start":null, <--------------------- "end":"08:00+03:00" } ] } }, ... } {code} It seems to me that the bug is in the JsonPointerImpl's isPositionToAdd method while it checks only the parent element's equivalence, instead of checking the whole path's equivalence. (I'm not 100% sure of that) Could you fix somehow the mentioned problem ? It would be very important for us and I guess that for a lot of other people as well. Thank you so much, have a nice day, Arnold Robert Turdean -- This message was sent by Atlassian Jira (v8.3.4#803005)