Marshal JSON
func Marshal(v interface{}) ([]byte, error)
json.Marshalpackage main
import "encoding/json"
import "fmt"
// struct members must be public to be marshalled (start with capital letter)
type Abc struct {
X string `json:"x"`
Y string `json:"y"`
}
func main() {
res2D := Abc {
X: "tom",
Y: "the best",}
mesg, _ := json.Marshal(res2D)
fmt.Printf("%V\n",res2D)
fmt.Println(string(mesg))
}