config_json.go 370 B

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