|
@ -97,32 +97,59 @@ func MapStringToInterface(src map[string]string) map[string]interface{} { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//将interface转成map[string]interface
|
|
|
//将interface转成map[string]interface
|
|
|
func InterfaceToMapInterface(data interface{})(map[string]interface{},error){ |
|
|
|
|
|
dataJson,err := json.Marshal(data) |
|
|
|
|
|
|
|
|
func InterfaceToMapInterface(data interface{}) (map[string]interface{}, error) { |
|
|
|
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil,err |
|
|
|
|
|
|
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var returnData map[string]interface{} |
|
|
var returnData map[string]interface{} |
|
|
err = json.Unmarshal(dataJson,&returnData) |
|
|
|
|
|
|
|
|
err = json.Unmarshal(dataJson, &returnData) |
|
|
|
|
|
|
|
|
return returnData,nil |
|
|
|
|
|
|
|
|
return returnData, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//将interface转成map[string]string
|
|
|
|
|
|
func InterfaceToMapString(data interface{}) (map[string]string, error) { |
|
|
|
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var returnData map[string]string |
|
|
|
|
|
err = json.Unmarshal(dataJson, &returnData) |
|
|
|
|
|
|
|
|
|
|
|
return returnData, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//将interface转成[]map[string]interface
|
|
|
//将interface转成[]map[string]interface
|
|
|
func InterfaceToMapInterfaceArr(data interface{})([]map[string]interface{},error){ |
|
|
|
|
|
dataJson,err := json.Marshal(data) |
|
|
|
|
|
|
|
|
func InterfaceToMapInterfaceArr(data interface{}) ([]map[string]interface{}, error) { |
|
|
|
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil,err |
|
|
|
|
|
|
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var returnData []map[string]interface{} |
|
|
var returnData []map[string]interface{} |
|
|
err = json.Unmarshal(dataJson,&returnData) |
|
|
|
|
|
|
|
|
err = json.Unmarshal(dataJson, &returnData) |
|
|
|
|
|
|
|
|
|
|
|
return returnData, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//将interface转成[]map[string]string
|
|
|
|
|
|
func InterfaceToMapStringArr(data interface{}) ([]map[string]string, error) { |
|
|
|
|
|
dataJson, err := json.Marshal(data) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var returnData []map[string]string |
|
|
|
|
|
err = json.Unmarshal(dataJson, &returnData) |
|
|
|
|
|
|
|
|
return returnData,nil |
|
|
|
|
|
|
|
|
return returnData, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|