示例#1
0
// JsonMarshaller is an example of a MarshalMethod that is passed to NewEncode().
//
// If a different data marshaller is desired, such as XML, YAML, etc.  Use this as a template.
func JsonMarshaller(in interface{}, out *rpb.RpbContent) error {
	jsondata, err := json.Marshal(in)
	if err != nil {
		return err
	}
	out.Value = jsondata
	out.ContentType = []byte("application/json")
	return nil
}