Documentation ¶
Overview ¶
Package jsoneq checks if two values are equal as JSON.
Example ¶
package main import ( "fmt" "log" "github.com/suzuki-shunsuke/go-jsoneq/jsoneq" ) type ( Foo struct { Foo string `json:"foo"` } ) func checkResult(b bool, err error) { if err != nil { log.Fatal(err) } fmt.Println(b) } func main() { b, err := jsoneq.Equal( Foo{Foo: "bar"}, map[string]string{"foo": "bar"}, ) checkResult(b, err) // when a type of value is []byte, it is treated as JSON string b, err = jsoneq.Equal( Foo{Foo: "bar"}, []byte(`{"foo": "bar"}`), ) checkResult(b, err) }
Output: true true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
func Convert(x interface{}) (interface{}, error)
Convert converts a given value to an object which can be checked if it is equal to the other value as JSON.
func ConvertByte ¶
ConvertByte converts a byte array to an object which can be checked if it is equal to the other value as JSON.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.