Created
November 28, 2020 07:14
-
-
Save matthewoestreich/fc3a4ea22f9eda71060596020d8f9330 to your computer and use it in GitHub Desktop.
Pretty Print JSON strings in Golang
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
func prettyPrint(i interface{}) { | |
prettyJSON, err := json.MarshalIndent(i, "", " ") | |
if err != nil { | |
fmt.Printf("Error : %s \n", err.Error()) | |
} | |
fmt.Printf("%s\n", string(prettyJSON)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment