Compare commits
2 Commits
e228983e73
...
3faebb9145
Author | SHA1 | Date | |
---|---|---|---|
3faebb9145 | |||
5163fd6f49 |
14
map.go
14
map.go
@ -8,11 +8,11 @@
|
|||||||
package wrapper
|
package wrapper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"git.zhangdeman.cn/zhangdeman/easymap"
|
"git.zhangdeman.cn/zhangdeman/easymap"
|
||||||
"git.zhangdeman.cn/zhangdeman/serialize"
|
"git.zhangdeman.cn/zhangdeman/serialize"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -78,11 +78,13 @@ func EasyMapFromString(data string) Map {
|
|||||||
//
|
//
|
||||||
// Date : 16:12 2023/8/10
|
// Date : 16:12 2023/8/10
|
||||||
func EasyMapFromByte(data []byte) Map {
|
func EasyMapFromByte(data []byte) Map {
|
||||||
var tmpMap map[interface{}]interface{}
|
res := easymap.NewNormal()
|
||||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
jsonRes := gjson.Parse(string(data))
|
||||||
decoder.UseNumber()
|
jsonRes.ForEach(func(key, value gjson.Result) bool {
|
||||||
_ = decoder.Decode(&tmpMap)
|
res.Set(key.Value(), value.Value())
|
||||||
return EasyMap(tmpMap)
|
return true
|
||||||
|
})
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map ...
|
// Map ...
|
||||||
|
Loading…
Reference in New Issue
Block a user