2022-03-31 18:34:52 +02:00
|
|
|
package json
|
2019-07-05 11:24:18 -07:00
|
|
|
|
2019-08-13 11:32:12 -07:00
|
|
|
// JoinPatches joins array of serialized JSON patches to the single JSONPatch array
|
2022-04-01 07:26:47 +02:00
|
|
|
func JoinPatches(patches ...[]byte) []byte {
|
2019-08-13 11:32:12 -07:00
|
|
|
var result []byte
|
|
|
|
if len(patches) == 0 {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
result = append(result, []byte("[\n")...)
|
|
|
|
for index, patch := range patches {
|
|
|
|
result = append(result, patch...)
|
|
|
|
if index != len(patches)-1 {
|
|
|
|
result = append(result, []byte(",\n")...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = append(result, []byte("\n]")...)
|
|
|
|
return result
|
|
|
|
}
|