Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 780 Bytes

README.md

File metadata and controls

29 lines (20 loc) · 780 Bytes

tapao

Tapao is a simple wrapper for many serializers. First version of tapao supports MessagePack and JSON.

Usage

When using Marshal or Unmarshal, tapao set the default serializer to MessagePack. You can override it by providing With option.

in := "Hello World"

// default
out, err := tapao.Marshal(in)

// override with JSON serializer
out, err := tapao.Marshal(in, tapao.With(tapao.JSON))

Sometimes, you need to be flexible when unmarshalling. With tapao, you could set the fallback when primary serializer is failed.

var out string

// default to messagepack
err := tapao.Unmarshal(in, &out)

// try using different serializer when failed
err := tapao.Unmarshal(in, &out, tapao.With(tapao.JSON), tapao.FallbackWith(tapao.MessagePack))