gojsondiff
gojsondiff copied to clipboard
provide a common way to diff
func AnyJsonDiff(left interface{}, right interface{}) (gojsondiff.Diff, error) {
type Container struct {
Payload any
}
leftBs, err := json.Marshal(Container{left})
if err != nil {
return nil, err
}
rightBs, err := json.Marshal(Container{right})
if err != nil {
return nil, err
}
return gojsondiff.New().Compare(leftBs, rightBs)
}