try to simplify extractpatches
This commit is contained in:
parent
912c2d90b9
commit
16b7f42695
|
@ -58,24 +58,15 @@ func NewClient(c *http.Client) *Client {
|
|||
func (resp *DiffPatchResponse) ExtractPatches() ([]jsonpatch.Patch, error) {
|
||||
var patches []jsonpatch.Patch
|
||||
|
||||
var objs []map[string]any
|
||||
var objs []map[string]jsonpatch.Patch
|
||||
err := json.Unmarshal([]byte(*resp), &objs)
|
||||
if err != nil {
|
||||
return patches, err
|
||||
}
|
||||
|
||||
for _, obj := range objs {
|
||||
diff := obj["diff"]
|
||||
patch, err := json.Marshal(diff)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
p, err := jsonpatch.DecodePatch(patch)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
patches = append(patches, p)
|
||||
patch := obj["diff"]
|
||||
patches = append(patches, patch)
|
||||
}
|
||||
|
||||
return patches, err
|
||||
|
|
Loading…
Reference in New Issue