Beispiel #1
0
func (h *HttpClient) convert(r *Request, content string) error {
	um, _ := encoding.NewEncoder(encoding.JSON)
	if r.encodingType != 0 {
		um, _ = encoding.NewEncoder(r.encodingType)
	}
	um.UnMarshalStr(content, r.result)
	return nil

}
Beispiel #2
0
func (h *HttpClient) convertBody(data interface{}) string {
	if data == nil {
		return ""
	}
	encoder, _ := encoding.NewEncoder(encoding.JSON)
	body, _ := encoder.Marshal(data)
	return body
}
Beispiel #3
0
func printEncodedType(formatter cli.Formatter, encoder encoding.EncoderType) {
	e, _ := encoding.NewEncoder(encoder)
	str, _ := e.MarshalIndent(formatter)
	fmt.Println(str)
}