summaryrefslogtreecommitdiffstats
path: root/model/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/utils.go')
-rw-r--r--model/utils.go20
1 files changed, 20 insertions, 0 deletions
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