chourobin
1/20/2014 - 1:28 AM

Example creating structs on the fly

Example creating structs on the fly

// http://play.golang.org/p/TVFHKUHO2p

package main

import "fmt"
import "encoding/json"

func main() {
	type error struct {
		Message string `json:"message"`
	}
	mapD := map[string]interface{}{"error": error{Message: "hi"}}
	mapB, _ := json.Marshal(mapD)
	fmt.Println(string(mapB))
}