typora/note/Go/json转义HTML.md
2024-12-12 10:48:55 +08:00

11 lines
205 B
Markdown

### 1、NewEncoder
```go
writer := bytes.Buffer{}
encoder := json.NewEncoder(&writer)
encoder.SetEscapeHTML(false)
encoder.Encode(struct{ Name string }{Name: "1111"})
jsonStr := writer.String()
```