encoder不转义html

This commit is contained in:
白茶清欢 2023-09-01 18:32:03 +08:00
parent 25bed80472
commit 5f80644a31
1 changed files with 4 additions and 4 deletions

View File

@ -71,7 +71,9 @@ func (oj *ownJSON) UnmarshalWithNumberForString(input string, receiver interface
// Date : 21:56 2023/7/22
func (oj *ownJSON) MarshalForByte(input interface{}) []byte {
buffer := bytes.NewBuffer([]byte{})
_ = json.NewEncoder(buffer).Encode(input)
encoder := json.NewEncoder(buffer)
encoder.SetEscapeHTML(true)
_ = encoder.Encode(input)
return buffer.Bytes()
}
@ -81,9 +83,7 @@ func (oj *ownJSON) MarshalForByte(input interface{}) []byte {
//
// Date : 21:56 2023/7/22
func (oj *ownJSON) MarshalForString(input interface{}) string {
buffer := bytes.NewBuffer([]byte{})
_ = json.NewEncoder(buffer).Encode(input)
return buffer.String()
return string(oj.MarshalForByte(input))
}
// ConsoleOutput ...