Last active
April 21, 2020 01:34
-
-
Save donvito/58abe6ac15541279b07333e58e9e7749 to your computer and use it in GitHub Desktop.
print map as json
This file contains 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 ( | |
"encoding/json" | |
"fmt" | |
"log" | |
) | |
func main() { | |
m := make(map[string]string) | |
m["name"] = "Melvin" | |
b, err := json.MarshalIndent(m, "", " ") | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println(string(b)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment