Compare commits

..

2 Commits

14
map.go
View File

@ -8,11 +8,11 @@
package wrapper
import (
"bytes"
"encoding/json"
"errors"
"git.zhangdeman.cn/zhangdeman/easymap"
"git.zhangdeman.cn/zhangdeman/serialize"
"github.com/tidwall/gjson"
"reflect"
)
@ -78,11 +78,13 @@ func EasyMapFromString(data string) Map {
//
// Date : 16:12 2023/8/10
func EasyMapFromByte(data []byte) Map {
var tmpMap map[interface{}]interface{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.UseNumber()
_ = decoder.Decode(&tmpMap)
return EasyMap(tmpMap)
res := easymap.NewNormal()
jsonRes := gjson.Parse(string(data))
jsonRes.ForEach(func(key, value gjson.Result) bool {
res.Set(key.Value(), value.Value())
return true
})
return res
}
// Map ...