Add appends an "add" operation to patch. > The "add" operation performs one of the following functions, > depending upon what the target location references: > > o If the target location specifies an array index, a new value is > inserted into the array at the specified index. > > o If the tar
(path ...string)
| 49 | // > o If the target location specifies an object member that does exist, |
| 50 | // > that member's value is replaced. |
| 51 | func (patch *JSON6902) Add(path ...string) func(value any) *JSON6902 { |
| 52 | i := len(*patch) |
| 53 | f := func(value any) *JSON6902 { |
| 54 | (*patch)[i] = map[string]any{ |
| 55 | "op": "add", |
| 56 | "path": patch.pointer(path...), |
| 57 | "value": value, |
| 58 | } |
| 59 | return patch |
| 60 | } |
| 61 | |
| 62 | *patch = append(*patch, f) |
| 63 | |
| 64 | return f |
| 65 | } |
| 66 | |
| 67 | // Remove appends a "remove" operation to patch. |
| 68 | // |