Created
April 15, 2015 19:11
-
-
Save asmedrano/3d43a424999e909b1207 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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