json 序列化特殊字符不转义
This commit is contained in:
parent
5c584bcb76
commit
25bed80472
10
json.go
10
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 ...
|
||||
|
Loading…
Reference in New Issue
Block a user