Daniel created JOHNZON-311:
------------------------------

             Summary: Create.diff is only fetching the last new element
                 Key: JOHNZON-311
                 URL: https://issues.apache.org/jira/browse/JOHNZON-311
             Project: Johnzon
          Issue Type: Bug
          Components: Core
    Affects Versions: 1.2.4
            Reporter: Daniel
         Attachments: image-2020-04-28-19-37-14-933.png

Create.diff is only fetching the last new element and ignoring the others.

This will cause an error when applying the diference 

 

Ex:

 

!image-2020-04-28-19-37-14-933.png!

 

 

Code used

 

{"eventLogs": [\{"event": "event1"}]}

{"eventLogs": [\{"event": "event1"},\{"event": "event2"},\{"event": "event3"}]}

 

 

JsonValue source = readValues("\{\"eventLogs\": [{\"event\": \"event1\"}]}");
JsonValue target = readValues("\{\"eventLogs\": [{\"event\": 
\"event1\"},\{\"event\": \"event2\"},\{\"event\": \"event3\"}]}");
JsonPatch diff = Json.createDiff(source.asJsonObject(), target.asJsonObject());

 

private JsonValue readValues(String valuesToRead){
 JsonReader reader = Json.createReader(new StringReader(valuesToRead));
 JsonValue value = reader.readValue();
 reader.close();
 return value;
}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to