更新json文件

This commit is contained in:
白茶清欢 2022-05-14 15:05:20 +08:00
parent fe96264f73
commit 5c78dd1201
2 changed files with 17 additions and 6 deletions

View File

@ -16,6 +16,8 @@ var (
Hash *hash
// IP ...
IP *ip
// JSON ...
JSON *ownJSON
)
func init() {
@ -23,4 +25,5 @@ func init() {
File = &file{}
Hash = &hash{}
IP = &ip{}
JSON = &ownJSON{}
}

20
json.go
View File

@ -16,34 +16,42 @@ import (
"reflect"
)
// JSONUnmarshalWithNumber 解析json
// ownJSON ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 15:01 2022/5/14
type ownJSON struct {
}
// UnmarshalWithNumber 解析json
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 8:39 下午 2021/9/14
func JSONUnmarshalWithNumber(byteData []byte, receiver interface{}) error {
func (oj *ownJSON) UnmarshalWithNumber(byteData []byte, receiver interface{}) error {
decoder := json.NewDecoder(bytes.NewReader(byteData))
decoder.UseNumber()
return decoder.Decode(receiver)
}
// JSONUnmarshalWithNumberForIOReader ...
// UnmarshalWithNumberForIOReader ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 8:43 下午 2021/9/14
func JSONUnmarshalWithNumberForIOReader(ioReader io.ReadCloser, receiver interface{}) error {
func (oj *ownJSON) UnmarshalWithNumberForIOReader(ioReader io.ReadCloser, receiver interface{}) error {
decoder := json.NewDecoder(ioReader)
decoder.UseNumber()
return decoder.Decode(receiver)
}
// JSONConsoleOutput ...
// ConsoleOutput ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 5:45 下午 2021/11/5
func JSONConsoleOutput(data interface{}) {
func (oj *ownJSON) ConsoleOutput(data interface{}) {
var out bytes.Buffer
switch reflect.TypeOf(data).Kind() {
case reflect.Slice: