Last active
October 26, 2015 18:48
-
-
Save lucacervasio/58f7684576d7d07e369e to your computer and use it in GitHub Desktop.
creating json from map[string]interface
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
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