Supports:
- Primitives, arrays, maps, structs, time.Time and interface{}.
- Appengine *datastore.Key and datastore.Cursor.
- CustomEncoder/CustomDecoder interfaces for custom encoding.
- Extensions to encode type information.
- Fields renaming, e.g.
msgpack:"my_field_name"
. - Fields inlining, e.g.
msgpack:",inline"
. - Omitempty flag, e.g.
msgpack:",omitempty"
.
API docs: http://godoc.org/gopkg.in/vmihailenco/msgpack.v2. Examples: http://godoc.org/gopkg.in/vmihailenco/msgpack.v2#pkg-examples.
Install:
go get gopkg.in/vmihailenco/msgpack.v2
func ExampleMarshal() {
b, err := msgpack.Marshal(true)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", b)
// Output:
var out bool
err = msgpack.Unmarshal([]byte{0xc3}, &out)
if err != nil {
panic(err)
}
fmt.Println(out)
// Output: []byte{0xc3}
// true
}
Please go through examples to get an idea how to use this package.