Trying to implement a converter that can convert from JSON to MessagePack and from MessagePack to JSON.
bool, int family, uint family, string, float32, float64, array, slice, map, timestamp
bool, uint family,int family, string, float32, float64, primitive array/slice/map
func main() {
// Encode: Declare a map as a JSON object
m := map[string]interface{}{
"compact": true,
"schema" 0,
}
b, err := encoder.JsonToMsgPack(json)
if err != nil {
log.Fatalf("Convert JSON to msgpack occured error: %s", err.Error())
}
fmt.Printf("%x\n", b) // output: 82a7c3a600
// Decode
m2 := map[string]interface{}{}
err := decoder.MsgPackToJson(b, &m2)
if err != nil {
log.Fatalf("Convert msgpack to JSON occured error: %s", err.Error())
}
fmt.Println(m2)
}$ cd internal/encoder
$ go test -v .$ cd internal/dncoder
$ go test -v .Some complicated types are not supported such as nested slice/array/map with interface.