Browse Source

加入interfce转map方法

master
listen 3 years ago
parent
commit
11e307358a
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      map.go

+ 15
- 0
map.go View File

@ -1,6 +1,7 @@
package helper package helper
import ( import (
"encoding/json"
"errors" "errors"
"net/url" "net/url"
"sort" "sort"
@ -95,6 +96,20 @@ func MapStringToInterface(src map[string]string) map[string]interface{} {
return target return target
} }
//将interface转成map[string]interface
func InterfaceToMapInterface(data interface{})(map[string]interface{},error){
dataJson,err := json.Marshal(data)
if err != nil {
return nil,err
}
var returnData map[string]interface{}
err = json.Unmarshal(dataJson,&returnData)
return returnData,nil
}
/** /**
* 对map进行字典序排序 * 对map进行字典序排序
* @param data map[string]string * @param data map[string]string


Loading…
Cancel
Save