Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: Unmarshal does not handle structs with lowercase fields #8598
What does 'go version' print? 1.3 What steps reproduce the problem? If possible, include a link to a program on play.golang.org. 1. Run this: http://play.golang.org/p/EXzXy8Ec01 What happened? There is no error and the struct has no fields set What should have happened instead? The name field should have been set to foo. Please provide any additional information below. Apparently Unmarshal silently ignores field names that are lowercase. If I change the 'name' field in the struct to 'Name', then it works. This is especially painful as examples in effective go (e.g. https://golang.org/doc/effective_go.html#formatting) show structs with lowercase fields. Ideally, Unmarshal would handle structs with lowercase fields. If that isn't practical for some reason, the docs should mention it, and perhaps Unmarshal should return an error if passed a struct type which has no fields that are settable.
This issue was closed.