User Tools

Site Tools


Response example

resp.go
//
// $Id$
//
package main
 
import (
    "encoding/json"
    "fmt"
)
 
type Response struct {
    Error       bool        `json:"error"`
    Message     string      `json:"message,omitempty"`
    Result      interface{} `json:"result,omitempty"`
}
 
func main() {
    var resp Response
    resp.Message = ""
    jsonBytes, _ := json.Marshal(resp)
    fmt.Println(string(jsonBytes))
}
//EOF

out

$ go run map.go
{"error":false}