From 5163fd6f493149f2627651a307de50029cad569d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Mon, 20 May 2024 20:47:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DEasyMapFromByte=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- map.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/map.go b/map.go index bd7a355..eea2bc4 100644 --- a/map.go +++ b/map.go @@ -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 ...