Skip to content

Instantly share code, notes, and snippets.

@lucacervasio
Last active October 26, 2015 18:48
Show Gist options
  • Save lucacervasio/58f7684576d7d07e369e to your computer and use it in GitHub Desktop.
Save lucacervasio/58f7684576d7d07e369e to your computer and use it in GitHub Desktop.
creating json from map[string]interface
package main
import (
"encoding/json"
"fmt"
)
func main() {
fmt.Println("Hello, playground")
sm := make(map[string]interface{})
sm["numero"] = 2
sm["stringa"] = "ciao"
sm["array_of_int"] = []int{1, 2, 3}
sm["array_of_string"] = []string{"io", "tu", "enoi"}
sm["wan"] = map[string]string{"chiave1": "valore1", "chiave2": "valore"}
js, _ := json.Marshal(sm)
fmt.Println(string(js))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment