gitlab.com/evatix-go/core@v1.3.55/isany/JsonEqual.go (about) 1 package isany 2 3 import ( 4 "bytes" 5 "encoding/json" 6 ) 7 8 func JsonEqual( 9 left, right interface{}, 10 ) bool { 11 leftBytes, leftErr := json.Marshal(left) 12 rightBytes, rightErr := json.Marshal(right) 13 14 if leftErr != nil && rightErr != nil && rightErr.Error() != leftErr.Error() { 15 return false 16 } 17 18 if leftErr != nil || rightErr != nil { 19 return false 20 } 21 22 return bytes.Equal(leftBytes, rightBytes) 23 }