I'm trying to return a simple json in Go. This is a web app and here's a part of a handler:
func JsonTest1(w http.ResponseWriter, r *http.Request) {
test1 := "something1"
test2 := 456
j1 := []byte(fmt.Sprintf(`
{
data: {
"test1": %s,
"test2": %d
}
}
`, test1, test2))
j2, _ := json.Marshal(&j1)
w.Header().Set("Content-Type", "application/json")
w.Write(j2)
}
When I'm doing a request via curl, I receive something like:
CiAgICB7CiAgICAgIGRhdGE6IHsKICAgICAgICAicmVkaXJlY3RfdXJsIjogdGVzdF9yZWRpcl91cmwxLAogICAgICAgICJtZXNzYWdlIjogdGVzdCBtc2cgMQogICAgICB9CiAgICB9CiAg
Why? How to fix that?