From b085bc2d56bdc98101b8cb50848aee248d42af28 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Thu, 5 Nov 2015 23:32:44 +0100 Subject: PLT-857: Support for Incoming Webhooks - Try #2 --- model/utils.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'model/utils.go') diff --git a/model/utils.go b/model/utils.go index 681ade870..1e71836c1 100644 --- a/model/utils.go +++ b/model/utils.go @@ -17,6 +17,7 @@ import ( "time" ) +type StringInterface map[string]interface{} type StringMap map[string]string type StringArray []string type EncryptStringMap map[string]string @@ -125,6 +126,25 @@ func ArrayFromJson(data io.Reader) []string { } } +func StringInterfaceToJson(objmap map[string]interface{}) string { + if b, err := json.Marshal(objmap); err != nil { + return "" + } else { + return string(b) + } +} + +func StringInterfaceFromJson(data io.Reader) map[string]interface{} { + decoder := json.NewDecoder(data) + + var objmap map[string]interface{} + if err := decoder.Decode(&objmap); err != nil { + return make(map[string]interface{}) + } else { + return objmap + } +} + func IsLower(s string) bool { if strings.ToLower(s) == s { return true -- cgit v1.2.3-1-g7c22