Skip to content

provide a common way to diff #51

@cold-bin

Description

@cold-bin
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)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions