These two tests demonstrate an issue with objects changing in arrays. Deletions aren't detected correctly and the generated diff doesn't actually update the JSON object properly. This doesn't appear to be specific to my port to Jackson but I haven't fully ruled that out yet.
@Test
public void testArrayObjectsRotateLeft() {
String from = "{\"a\":[{\"b\":1},{\"c\":2},{\"d\":3}]}";
String to = "{\"a\":[{\"c\":2},{\"d\":3},{\"e\":4}]}";
String diff = "{\"~a[0]\":{\"-b\":0},\"-a[1]\":0,\"a[+2]\":{\"e\":4}}";
String d = JsonDiff.diff(from, to);
Assert.assertEquals(diff, d);
String p = JsonPatch.apply(from, diff);
Assert.assertEquals(to, p);
}
@Test
public void testArrayObjectsRotateRight() {
String from = "{\"a\":[{\"c\":2},{\"d\":3},{\"e\":4}]}";
String to = "{\"a\":[{\"b\":1},{\"c\":2},{\"d\":3}]}";
String diff = "{\"~a[0]\":{\"b\":1},\"a[+1]\":{\"c\":2},\"-a[2]\":0}";
String d = JsonDiff.diff(from, to);
Assert.assertEquals(diff, d);
String p = JsonPatch.apply(from, diff);
Assert.assertEquals(to, p);
}
These two tests demonstrate an issue with objects changing in arrays. Deletions aren't detected correctly and the generated diff doesn't actually update the JSON object properly. This doesn't appear to be specific to my port to Jackson but I haven't fully ruled that out yet.