encoder不转义html
This commit is contained in:
parent
25bed80472
commit
5f80644a31
8
json.go
8
json.go
@ -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 ...
|
||||
|
Loading…
Reference in New Issue
Block a user