encoder/encoder.go
func (_ JsonEncoder) Encode(v ...interface{}) ([]byte, error) {
	var data interface{} = v
	var result interface{}

	if v == nil {
		// So that empty results produces `[]` and not `null`
		data = []interface{}{}
	} else if len(v) == 1 {
		data = v[0]
	}

	t := reflect.TypeOf(data)

	if t.Kind() == reflect.Ptr {
		t = t.Elem()
	}

	if t.Kind() == reflect.Struct {
		result = copyStruct(reflect.ValueOf(data), t).Interface()
	} else {
		result = data
	}

	b, err := json.Marshal(result)

	return b, err
}
func (_ JsonEncoder) Encode(v ...interface{}) ([]byte, error) {
	var data interface{} = v
	var result interface{}

	if v == nil {
		// So that empty results produces `[]` and not `null`
		data = []interface{}{}
	} else if len(v) == 1 {
		data = v[0]
	}

	t := reflect.TypeOf(data)

	if t.Kind() == reflect.Ptr {
		t = t.Elem()
	}

	if t.Kind() == reflect.Struct {
		result = copyStruct(reflect.ValueOf(data), t).Interface()
	} else {
		result = data
	}

	b, err := json.Marshal(result)

	return b, err
}
// jsonEncoder is an Encoder that produces JSON-formatted responses.