Documentation ¶
Overview ¶
Package jsoncmp is a Go JSON value comparison library for testing.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff returns a compared result of differences between two values. It returns an empty string if there is no differences, but else returns a report as string.
Example ¶
Use Diff for comparing two JSON values and printing out human-redable errors.
package main import ( "fmt" "github.com/hgsgtk/jsoncmp" ) // Use Diff for comparing two JSON values and printing out human-redable errors. func main() { x := ` { "name": "Tom Bake", "age": 41 }` y := ` { "name": "Tom Bake", "age": 42 } ` var t stubT if diff := jsoncmp.Diff(x, y); diff != "" { t.Errorf("jsoncmp.Diff() got differs: (-got +want)\n%s", diff) } } type stubT struct{} func (t *stubT) Errorf(format string, args ...interface{}) { fmt.Printf(format+"\n", args...) }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.