Open robseed opened 4 years ago
Error reproduced, I'm looking into it. Especially with the error message it is indeed quite strange.
OK, the problem has to do with JSON Pointer semantics. When processing a list of diffs to introduce move
ops, the assumption is the a numerical path segment is an array index (which means it has to be taken into account in adjusting the resulting paths).
That is incorrect: JSON Pointer doesn't actually know whether a path segment refers to array or object. For example, the path /0/abc
will correctly evaluate against both of these documents: {"0": {"abc": true}}
and [{"abc":true}]
.
Solving this requires modifying JsonDiff.introduceMoveOperation
and JsonDiff.updatePath
to take the source document into account; I'm working on it, but it'll take a bit of time.
Expected Behavior
If JsonDiff.asJson succeeds then JsonPatch.apply should succeed
Actual Behavior
JsonPatch.apply fails with
[MOVE Operation] Missing field
Steps to Reproduce the Problem
Specifications
The json looks contrived, but it is a real world example from comparing facebook posts. Java 1.8, Jackson 2.9.9, zjsonpatch 0.4.9