Skip to content

Instantly share code, notes, and snippets.

@donvito
Last active April 21, 2020 01:34
Show Gist options
  • Save donvito/58abe6ac15541279b07333e58e9e7749 to your computer and use it in GitHub Desktop.
Save donvito/58abe6ac15541279b07333e58e9e7749 to your computer and use it in GitHub Desktop.
print map as json
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