easy map
This commit is contained in:
parent
118ef5d59a
commit
dac3a32e6f
17
easymap.go
17
easymap.go
@ -21,7 +21,7 @@ import (
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:02 2023/8/10
|
||||
func EasyMap(mapData any) Map {
|
||||
func EasyMap(mapData any) easymap.EasyMap {
|
||||
m, _ := EasyMapWithError(mapData)
|
||||
return m
|
||||
}
|
||||
@ -31,7 +31,7 @@ func EasyMap(mapData any) Map {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:06 2023/8/10
|
||||
func EasyMapWithError(mapData any) (Map, error) {
|
||||
func EasyMapWithError(mapData any) (easymap.EasyMap, error) {
|
||||
if nil == mapData {
|
||||
return easymap.NewNormal(), nil
|
||||
}
|
||||
@ -58,7 +58,7 @@ func EasyMapWithError(mapData any) (Map, error) {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:11 2023/8/10
|
||||
func EasyMapFromStruct(data any) Map {
|
||||
func EasyMapFromStruct(data any) easymap.EasyMap {
|
||||
byteData, _ := json.Marshal(data)
|
||||
return EasyMapFromByte(byteData)
|
||||
}
|
||||
@ -68,7 +68,7 @@ func EasyMapFromStruct(data any) Map {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:12 2023/8/10
|
||||
func EasyMapFromString(data string) Map {
|
||||
func EasyMapFromString(data string) easymap.EasyMap {
|
||||
return EasyMapFromByte([]byte(data))
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ func EasyMapFromString(data string) Map {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:12 2023/8/10
|
||||
func EasyMapFromByte(data []byte) Map {
|
||||
func EasyMapFromByte(data []byte) easymap.EasyMap {
|
||||
res := easymap.NewNormal()
|
||||
jsonRes := gjson.Parse(string(data))
|
||||
jsonRes.ForEach(func(key, value gjson.Result) bool {
|
||||
@ -86,10 +86,3 @@ func EasyMapFromByte(data []byte) Map {
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
// Map ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:14 2023/8/10
|
||||
type Map easymap.EasyMap
|
||||
|
Loading…
Reference in New Issue
Block a user