1. 程式人生 > >golang中map結構轉換成寄送

golang中map結構轉換成寄送

package main

import (
"encoding/json"
"fmt"
)

func main() {
	m := make(map[string]interface{}, 4)
	m["name"] = "wilson"
	m["lang"] = []string{"go", "python", "java"}
	m["isok"] = true
	m["price"] = 5.55

	result, err := json.Marshal(m)
	if err != nil {
		return
	}
	fmt.Println("result = ", string(result))
}