How to stop json.Marshal from escaping < and>?

后端 未结 5 579
甜味超标
甜味超标 2020-12-24 12:48
package main

import \"fmt\"
import \"encoding/json\"

type Track struct {
    XmlRequest string `json:\"xmlRequest\"`
}

func main() {
    message := new(Track)
            


        
5条回答
  •  情话喂你
    2020-12-24 13:28

    Custom function is not kind of the best solution.

    How about another library to solve this. I use gabs

    import

    go get "github.com/Jeffail/gabs"

    use

    message := new(Track)
    resultJson,_:=gabs.Consume(message)
    
    fmt.Println(string(resultJson.EncodeJSON()))
    

    I solve that problem like this.

提交回复
热议问题