config_json.go 361 B

1234567891011121314151617
  1. // +build json
  2. package transport
  3. import "encoding/json"
  4. func (this *Config) UnmarshalJSON(data []byte) error {
  5. type JsonConfig struct {
  6. ConnectionReuse bool `json:"connectionReuse"`
  7. }
  8. jsonConfig := new(JsonConfig)
  9. if err := json.Unmarshal(data, jsonConfig); err != nil {
  10. return err
  11. }
  12. this.ConnectionReuse = jsonConfig.ConnectionReuse
  13. return nil
  14. }