binary/reflect handles JSON

This commit is contained in:
Jae Kwon
2015-01-05 14:04:42 -08:00
parent 13ca6fb241
commit d4e9b747d3
6 changed files with 499 additions and 170 deletions
+9
View File
@@ -15,6 +15,15 @@ func BinaryBytes(o interface{}) []byte {
return w.Bytes()
}
func JSONBytes(o interface{}) []byte {
w, n, err := new(bytes.Buffer), new(int64), new(error)
WriteJSON(o, w, n, err)
if *err != nil {
panic(err)
}
return w.Bytes()
}
// NOTE: does not care about the type, only the binary representation.
func BinaryEqual(a, b interface{}) bool {
aBytes := BinaryBytes(a)