切换序列化库
This commit is contained in:
35
string.go
35
string.go
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user