Compare commits

...

2 Commits

14
map.go
View File

@ -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 ...