@@ -13,6 +13,7 @@ A PHP implementation for finding unordered diff between two `JSON` documents.
13
13
* To detect breaking changes by analyzing removals and changes from original ` JSON ` .
14
14
* To keep original order of object sets (for example ` swagger.json ` [ parameters] ( https://swagger.io/docs/specification/describing-parameters/ ) list).
15
15
* To make and apply JSON Patches, specified in [ RFC 6902] ( http://tools.ietf.org/html/rfc6902 ) from the IETF.
16
+ * To retrieve and modify data by [ JSON Pointer] ( http://tools.ietf.org/html/rfc6901 ) .
16
17
17
18
## Installation
18
19
@@ -32,6 +33,8 @@ composer require swaggest/json-diff
32
33
33
34
## Library usage
34
35
36
+ ### ` JsonDiff `
37
+
35
38
Create ` JsonDiff ` object from two values (` original ` and ` new ` ).
36
39
37
40
``` php
@@ -53,42 +56,76 @@ $r = new JsonDiff(
53
56
54
57
On created object you have several handy methods.
55
58
56
- ### ` getPatch `
57
- Returns ` JsonPatch ` of difference
59
+ #### ` getPatch `
60
+ Returns [ ` JsonPatch ` ] ( #jsonpatch ) of difference
58
61
59
- ### ` getRearranged `
62
+ #### ` getRearranged `
60
63
Returns new value, rearranged with original order.
61
64
62
- ### ` getRemoved `
65
+ #### ` getRemoved `
63
66
Returns removals as partial value of original.
64
67
65
- ### ` getRemovedPaths `
68
+ #### ` getRemovedPaths `
66
69
Returns list of ` JSON ` paths that were removed from original.
67
70
68
- ### ` getRemovedCnt `
71
+ #### ` getRemovedCnt `
69
72
Returns number of removals.
70
73
71
- ### ` getAdded `
74
+ #### ` getAdded `
72
75
Returns additions as partial value of new.
73
76
74
- ### ` getAddedPaths `
77
+ #### ` getAddedPaths `
75
78
Returns list of ` JSON ` paths that were added to new.
76
79
77
- ### ` getAddedCnt `
80
+ #### ` getAddedCnt `
78
81
Returns number of additions.
79
82
80
- ### ` getModifiedOriginal `
83
+ #### ` getModifiedOriginal `
81
84
Returns modifications as partial value of original.
82
85
83
- ### ` getModifiedNew `
86
+ #### ` getModifiedNew `
84
87
Returns modifications as partial value of new.
85
88
86
- ### ` getModifiedPaths `
89
+ #### ` getModifiedPaths `
87
90
Returns list of ` JSON ` paths that were modified from original to new.
88
91
89
- ### ` getModifiedCnt `
92
+ #### ` getModifiedCnt `
90
93
Returns number of modifications.
91
94
95
+ ### ` JsonPatch `
96
+
97
+ #### ` import `
98
+ Creates ` JsonPatch ` instance from ` JSON ` -decoded data.
99
+
100
+ #### ` export `
101
+ Creates patch data from ` JsonPatch ` object.
102
+
103
+ #### ` op `
104
+ Adds operation to ` JsonPatch ` .
105
+
106
+ #### ` apply `
107
+ Applies patch to ` JSON ` -decoded data.
108
+
109
+ ### ` JsonPointer `
110
+
111
+ #### ` escapeSegment `
112
+ Escapes path segment.
113
+
114
+ #### ` splitPath `
115
+ Creates array of unescaped segments from ` JSON Pointer ` string.
116
+
117
+ #### ` add `
118
+ Adds value to data at path specified by segments.
119
+
120
+ #### ` get `
121
+ Gets value from data at path specified by segments.
122
+
123
+ #### ` getByPointer `
124
+ Gets value from data at path specified ` JSON Pointer ` string.
125
+
126
+ #### ` remove `
127
+ Removes value from data at path specified by segments.
128
+
92
129
## Example
93
130
94
131
``` php
0 commit comments