We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
go version go1.11beta3 linux/amd64
go version go1.10.3 linux/amd64
func main() { err := errors.New("abc") m := map[string]interface{}{ "error": err, } data, _ := json.Marshal(m) fmt.Println(string(data)) }
{"error":"abc"}
{"error":{}}
The text was updated successfully, but these errors were encountered:
You're marshaling an interface. And it so happens that the errors package returns a struct with no exported fields, hence {}: https://golang.org/src/errors/errors.go?s=293:320#L1
errors
{}
If you want to print the error string, use "error": err.Error().
"error": err.Error()
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?go version go1.11beta3 linux/amd64
Does this issue reproduce with the latest release?
go version go1.10.3 linux/amd64
What did you do?
What did you expect to see?
What did you see instead?
{"error":{}}
The text was updated successfully, but these errors were encountered: