github.com/wgh-/mattermost-server@v4.8.0-rc2+incompatible/model/team_search.go (about) 1 // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package model 5 6 import ( 7 "encoding/json" 8 "io" 9 ) 10 11 type TeamSearch struct { 12 Term string `json:"term"` 13 } 14 15 // ToJson convert a TeamSearch to json string 16 func (c *TeamSearch) ToJson() string { 17 b, err := json.Marshal(c) 18 if err != nil { 19 return "" 20 } 21 22 return string(b) 23 } 24 25 // TeamSearchFromJson decodes the input and returns a TeamSearch 26 func TeamSearchFromJson(data io.Reader) *TeamSearch { 27 decoder := json.NewDecoder(data) 28 var cs TeamSearch 29 err := decoder.Decode(&cs) 30 if err == nil { 31 return &cs 32 } 33 34 return nil 35 }