code: func (abi *ABI) UnmarshalJSON(data []byte) error {
  	var fields []struct {
  		Type      string
  		Name      string
  		Constant  bool
  		Anonymous bool
  		Inputs    []Argument
  		Outputs   []Argument
  	}
  
  	if err := json.Unmarshal(data, &fields); err != nil {
  		return err
  	}
  
  	abi.Methods = make(map[string]Method)
  	abi.Events = make(map[string]Event)
  	for _, field := range fields {
  		switch field.Type {
  		case "constructor":
  			abi.Constructor = Method{
  				Inputs: field.Inputs,
  			}
  		// empty defaults to function according to the abi spec
  		case "function", "":
  			abi.Methods[field.Name] = Method{
  				Name:    field.Name,
  				Const:   field.Constant,
  				Inputs:  field.Inputs,
  				Outputs: field.Outputs,
  			}
  		case "event":
  			abi.Events[field.Name] = Event{
  				Name:      field.Name,
  				Anonymous: field.Anonymous,
  				Inputs:    field.Inputs,
  			}
  		}
  	}
  
  	return nil
  }
docs: // UnmarshalJSON implements json.Unmarshaler interface