diff --git a/json.go b/json.go index 284cbf6..52cb400 100644 --- a/json.go +++ b/json.go @@ -70,8 +70,9 @@ func (oj *ownJSON) UnmarshalWithNumberForString(input string, receiver interface // // Date : 21:56 2023/7/22 func (oj *ownJSON) MarshalForByte(input interface{}) []byte { - byteData, _ := json.Marshal(input) - return byteData + buffer := bytes.NewBuffer([]byte{}) + _ = json.NewEncoder(buffer).Encode(input) + return buffer.Bytes() } // MarshalForString 序列化并返回字符串 @@ -80,8 +81,9 @@ func (oj *ownJSON) MarshalForByte(input interface{}) []byte { // // Date : 21:56 2023/7/22 func (oj *ownJSON) MarshalForString(input interface{}) string { - byteData := oj.MarshalForByte(input) - return string(byteData) + buffer := bytes.NewBuffer([]byte{}) + _ = json.NewEncoder(buffer).Encode(input) + return buffer.String() } // ConsoleOutput ...