切换序列化库

This commit is contained in:
白茶清欢 2023-08-11 13:56:40 +08:00
parent 65186fe23b
commit bff3fa8566
4 changed files with 31 additions and 22 deletions

4
go.mod
View File

@ -2,10 +2,12 @@ module git.zhangdeman.cn/zhangdeman/wrapper
go 1.20
require git.zhangdeman.cn/zhangdeman/util v0.0.0-20230810063945-842592611562
require git.zhangdeman.cn/zhangdeman/util v0.0.0-20230811055014-2e36e7b1ac67
require (
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20230811030300-6f850372c88c // indirect
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20230307094841-e437ba87af10 // indirect
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20230811032817-e6ad534a9a10 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Jeffail/gabs v1.4.0 // indirect
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect

6
go.sum
View File

@ -1,9 +1,15 @@
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20230811030300-6f850372c88c h1:Dan3iSVU6XTKt8r3/qixfPHPpfLZjkYlPmaJios7wtE=
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20230811030300-6f850372c88c/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20230307094841-e437ba87af10 h1:+Lg4vXFEiWVKjhUJdXuoP0AgjGT49oqJ3301STnZErk=
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20230307094841-e437ba87af10/go.mod h1:+Lc0zYF8sylRi75A7NGmObrLxugwAZa8WVpWh2eh5X0=
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20230811032817-e6ad534a9a10 h1:orhcMAKrcOajsBJCgssnb9O8YcLsPJvWuXF511gs5dc=
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20230811032817-e6ad534a9a10/go.mod h1:CzX5/WwGDTnKmewarnjkK5XcSRbgszTQTdTL3OUc/s4=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20230801092344-773ac512f305 h1:6Bs/cQP+eKABHB/01uHQI15PwKbo7n8HNx7nIFUGBp0=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20230801092344-773ac512f305/go.mod h1:trYFOShINaQBvinQrH4A0G2kfL22Y2lygEcAiGDt/sc=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20230810063945-842592611562 h1:wo0r4mexqkPzQ1SZOw5z8A7FJ3ne1G6A/qWR3iaqlhw=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20230810063945-842592611562/go.mod h1:trYFOShINaQBvinQrH4A0G2kfL22Y2lygEcAiGDt/sc=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20230811055014-2e36e7b1ac67 h1:risi3/+SuH+snq/+/1dvqDrNyiclCi5weHMixg7IgO8=
git.zhangdeman.cn/zhangdeman/util v0.0.0-20230811055014-2e36e7b1ac67/go.mod h1:tPl6isAsRQLZrX8G3/8fCdhN4OcZypdmdHR/PDkd2PY=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/Jeffail/gabs v1.4.0 h1://5fYRRTq1edjfIrQGvdkcd22pkYUrHZ5YC/H2GJVAo=

View File

@ -10,7 +10,7 @@ package wrapper
import (
"encoding/json"
"errors"
"git.zhangdeman.cn/zhangdeman/util"
"git.zhangdeman.cn/zhangdeman/serialize"
"reflect"
)
@ -112,7 +112,7 @@ func (ot *ObjectType) ToMapStringAny() ObjectResult {
if ot.IsNil() {
return res
}
res.Err = util.JSON.UnmarshalWithNumber(ot.byteData, &res.Value)
res.Err = serialize.JSON.UnmarshalWithNumber(ot.byteData, &res.Value)
return res
}
@ -128,7 +128,7 @@ func (ot *ObjectType) ToStruct(receiver interface{}) error {
if ot.IsNil() {
return errors.New("data is nil")
}
return util.JSON.UnmarshalWithNumber(ot.byteData, receiver)
return serialize.JSON.UnmarshalWithNumber(ot.byteData, receiver)
}
// ToStructIgnoreErr ...
@ -143,5 +143,5 @@ func (ot *ObjectType) ToStructIgnoreErr(receiver interface{}) {
if ot.IsNil() {
return
}
_ = util.JSON.UnmarshalWithNumber(ot.byteData, receiver)
_ = serialize.JSON.UnmarshalWithNumber(ot.byteData, receiver)
}

View File

@ -10,6 +10,7 @@ package wrapper
import (
"crypto/md5"
"errors"
"git.zhangdeman.cn/zhangdeman/serialize"
"git.zhangdeman.cn/zhangdeman/util"
"io"
"strings"
@ -499,7 +500,7 @@ func (str String) ToObject() ObjectResult {
Err: nil,
}
)
res.Err = util.JSON.UnmarshalWithNumber([]byte(str), &res.Value)
res.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &res.Value)
return res
}
@ -512,7 +513,7 @@ func (str String) ToStruct(receiver interface{}) error {
if nil == receiver {
return errors.New("receiver is nil")
}
return util.JSON.UnmarshalWithNumber([]byte(str), receiver)
return serialize.JSON.UnmarshalWithNumber([]byte(str), receiver)
}
// ToInt8Slice ...
@ -527,7 +528,7 @@ func (str String) ToInt8Slice(splitChar ...string) Int8SliceResult {
}
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
var (
@ -561,7 +562,7 @@ func (str String) ToInt16Slice(splitChar ...string) Int16SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]int16, 0)
@ -591,7 +592,7 @@ func (str String) ToInt32Slice(splitChar ...string) Int32SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]int32, 0)
@ -621,7 +622,7 @@ func (str String) ToInt64Slice(splitChar ...string) Int64SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]int64, 0)
@ -650,7 +651,7 @@ func (str String) ToIntSlice(splitChar ...string) IntSliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]int, 0)
@ -680,7 +681,7 @@ func (str String) ToUint8Slice(splitChar ...string) Uint8SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]uint8, 0)
@ -710,7 +711,7 @@ func (str String) ToUint16Slice(splitChar ...string) Uint16SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]uint16, 0)
@ -740,7 +741,7 @@ func (str String) ToUint32Slice(splitChar ...string) Uint32SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]uint32, 0)
@ -770,7 +771,7 @@ func (str String) ToUint64Slice(splitChar ...string) Uint64SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]uint64, 0)
@ -799,7 +800,7 @@ func (str String) ToUintSlice(splitChar ...string) UintSliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]uint, 0)
@ -829,7 +830,7 @@ func (str String) ToBoolSlice(splitChar ...string) BoolSliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]bool, 0)
@ -859,7 +860,7 @@ func (str String) ToFloat32Slice(splitChar ...string) Float32SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]float32, 0)
@ -888,7 +889,7 @@ func (str String) ToFloat64Slice(splitChar ...string) Float64SliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
res := make([]float64, 0)
@ -936,7 +937,7 @@ func (str String) ToStringSlice(splitChar ...string) StringSliceResult {
isSplit := len(splitChar) > 0
if !isSplit {
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}
result.Value = strings.Split(string(str), splitChar[0])
@ -954,7 +955,7 @@ func (str String) ToAnySlice() AnySliceResult {
Err: nil,
}
result.Err = util.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
result.Err = serialize.JSON.UnmarshalWithNumber([]byte(str), &result.Value)
return result
}