Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package main
import "fmt"
import "encoding/json"
var m map[string]string
var mDup map[string]string
func main() {
m = make(map[string]string)
m["key1"] = "value1"
m["key2"] = "value2"
m["key3"] = "value3"
fmt.Println(m)
data, _ := json.Marshal(m)
fmt.Printf("%s\n", data)
dataIndent, _ := json.MarshalIndent(m, "", " ")
fmt.Printf("%s\n", dataIndent)
err := json.Unmarshal(dataIndent, &mDup)
if err != nil {
fmt.Println(err)
}
fmt.Println(mDup)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.