Skip to content

Instantly share code, notes, and snippets.

@asmedrano
Created April 15, 2015 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asmedrano/3d43a424999e909b1207 to your computer and use it in GitHub Desktop.
Save asmedrano/3d43a424999e909b1207 to your computer and use it in GitHub Desktop.
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