Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import "fmt"
import "encoding/json"
type My struct {
Name string
}
func (m My) MarshalJSON() ([]byte, error) {
return json.Marshal(m.Name + "Asdf")
}
func main() {
t := My{"Angel"}
j, err := json.Marshal(t)
fmt.Println(err, string(j))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment