code: func (f *SuggestField) MarshalJSON() ([]byte, error) {
  	source := make(map[string]interface{})
  
  	if f.inputs != nil {
  		switch len(f.inputs) {
  		case 1:
  			source["input"] = f.inputs[0]
  		default:
  			source["input"] = f.inputs
  		}
  	}
  
  	if f.weight >= 0 {
  		source["weight"] = f.weight
  	}
  
  	switch len(f.contextQueries) {
  	case 0:
  	case 1:
  		src, err := f.contextQueries[0].Source()
  		if err != nil {
  			return nil, err
  		}
  		source["contexts"] = src
  	default:
  		ctxq := make(map[string]interface{})
  		for _, query := range f.contextQueries {
  			src, err := query.Source()
  			if err != nil {
  				return nil, err
  			}
  			m, ok := src.(map[string]interface{})
  			if !ok {
  				return nil, errors.New("SuggesterContextQuery must be of type map[string]interface{}")
  			}
  			for k, v := range m {
  				ctxq[k] = v
  			}
  		}
  		source["contexts"] = ctxq
  	}
  
  	return json.Marshal(source)
  }
docs: // MarshalJSON encodes SuggestField into JSON.