-
Notifications
You must be signed in to change notification settings - Fork 6
JSON
Zelenko edited this page Oct 2, 2018
·
7 revisions
How to create JSON object:
package main
import (
"encoding/json"
"fmt"
)
func main() {
data := make(map[string]interface{})
data["name"] = "John Doe"
data["title"] = "Front End Developer"
data["phone"] = map[string]interface{}{
"mobil": "123-456-799",
"office": "964-587-154",
}
data["email"] = "[email protected]"
jsonData, err := json.Marshal(data)
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(string(jsonData))
}