37 lines
827 B
Go
37 lines
827 B
Go
|
// Package util...
|
||
|
//
|
||
|
// Description : json 工具函数
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 2021-09-14 8:38 下午
|
||
|
package util
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"encoding/json"
|
||
|
"io"
|
||
|
)
|
||
|
|
||
|
// JSONUnmarshalWithNumber 解析json
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 8:39 下午 2021/9/14
|
||
|
func JSONUnmarshalWithNumber(byteData []byte, receiver interface{}) error {
|
||
|
decoder := json.NewDecoder(bytes.NewReader(byteData))
|
||
|
decoder.UseNumber()
|
||
|
return decoder.Decode(receiver)
|
||
|
}
|
||
|
|
||
|
// JSONUnmarshalWithNumberForIOReader ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 8:43 下午 2021/9/14
|
||
|
func JSONUnmarshalWithNumberForIOReader(ioReader io.ReadCloser, receiver interface{}) error {
|
||
|
decoder := json.NewDecoder(ioReader)
|
||
|
decoder.UseNumber()
|
||
|
return decoder.Decode(receiver)
|
||
|
}
|