How to prevent converting <p>
to \u003cp\u003e
in json.Marshal
?
package main
import (
"encoding/json"
"fmt"
)
type User struct {
Name string
}
func main() {
user := User{Name: "<p>Frank</p>"}
b, err := json.Marshal(&user)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(user)
fmt.Println(string(b))
}
It outputs:
{<p>Frank</p>}
{"Name":"\u003cp\u003eFrank\u003c/p\u003e"}