You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-3Lines changed: 35 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ $r = new JsonDiff(
57
57
```
58
58
59
59
Available options:
60
-
*`REARRANGE_ARRAYS` is an option to enable arrays rearrangement to minimize the difference.
60
+
*`REARRANGE_ARRAYS` is an option to enable [arrays rearrangement](#arraysrearrangement) to minimize the difference.
61
61
*`STOP_ON_DIFF` is an option to improve performance by stopping comparison when a difference is found.
62
62
*`JSON_URI_FRAGMENT_ID` is an option to use URI Fragment Identifier Representation (example: "#/c%25d"). If not set default JSON String Representation (example: "/c%d").
63
63
*`SKIP_JSON_PATCH` is an option to improve performance by not building JsonPatch for this diff.
@@ -67,8 +67,6 @@ Available options:
67
67
68
68
Options can be combined, e.g. `JsonDiff::REARRANGE_ARRAYS + JsonDiff::STOP_ON_DIFF`.
69
69
70
-
On created object you have several handy methods.
71
-
72
70
#### `getDiffCnt`
73
71
Returns total number of differences
74
72
@@ -248,6 +246,40 @@ Due to magical methods and other restrictions PHP classes can not be reliably ma
248
246
There is support for objects of PHP classes in `JsonPointer` with limitations:
249
247
*`null` is equal to non-existent
250
248
249
+
## Arrays Rearrangement
250
+
251
+
When `JsonDiff::REARRANGE_ARRAYS` option is enabled, array items are ordered to match the original array.
252
+
253
+
If arrays contain homogenous objects, and those objects have a common property with unique values, array is
254
+
ordered to match placement of items with same value of such property in the original array.
0 commit comments