I am trying to create a JSON string from a struct:
package main
import "fmt"
func main() {
type CommentResp struct {
Id string `json: "id"`
Name string `json: "name"`
}
stringa := CommentResp{
Id: "42",
Name: "Foo",
}
fmt.Println(stringa)
}
This code prints {42 foo}
, but I expected {"Id":"42","Name":"Foo"}
.