golang json marshal将标签转换为utf符号

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"}

playground

This is already explained in this question. In short - you can create your own Marshaller implementation if you need to preserve these characters, but even encoded the json output will be a perfectly valid one and should not break anything.