Created
January 26, 2018 07:49
-
-
Save knzm/bb7f68184dbb790d45a19b0b8cd316d0 to your computer and use it in GitHub Desktop.
This file contains 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" | |
) | |
type Response struct { | |
Status string `json:"status"` | |
Error string `json:"error"` | |
ErrorCode string `json:"error_code"` | |
DebugInfo interface{} `json:"debug_info,omitempty"` | |
} | |
func main() { | |
b, _ := json.Marshal(Response{}) | |
fmt.Printf("%s\n", b) | |
var x *int | |
res := Response{ | |
DebugInfo: x, | |
} | |
b, _ = json.Marshal(res) | |
fmt.Printf("%s\n", b) | |
} |
This file contains 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
{"status":"","error":"","error_code":""} | |
{"status":"","error":"","error_code":"","debug_info":null} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment