Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Diff ¶
type Diff struct {
Err error // error message if any (can't unmarsal into ...)
HasDiff bool // True if there is a difference or error makes it impossible to check
// contains filtered or unexported fields
}
Diff is a result of comparison operation. Provides list of items that describe difference between objects piece by piece
func Compare ¶
func Compare(a, b interface{}) Diff
Compare produces list of diff items that define difference between objects "a" and "b". Note: if objects are equal, all diff items will have Resolution of type TypeEquals
func CompareFiles ¶
CompareFiels will read in 2 files, hopefully both JSON, and perform the compare on them.
func CompareMemToFile ¶
CompareMemToFile compares an in memory structure to a file. The primary intended use for this is in testing code where an in-memory structure has been created and a correct reference copy is in a directory on disk.
d := jsondiff.Compare ( inMem, "./testdir/test1.json" )
if d.HasDiff {
t.Error ( "failed to pass test1" )
}
type DiffItem ¶
type DiffItem struct {
Key string
ValueA interface{}
Resolution ResolutionType
ValueB interface{}
}
DiffItem defines a difference between 2 items with resolution type
type ResolutionType ¶
type ResolutionType int
ResolutionType defines a type of comparison: equality, non-equality, new sub-diff and so on
const ( TypeEquals ResolutionType = iota TypeNotEquals TypeAdded TypeRemoved TypeDiff )
func (ResolutionType) String ¶
func (rt ResolutionType) String() string
String allows for printing of ResolutionType as a name