On Wed, Mar 18, 2015 at 3:14 PM, forfader <
mbur...@gmail.com> wrote:
> type User struct {
> name string
> emailAddress string
> password string
> userId string
> }
> When I run this, json.Unmarshal does not return an error, but the unmarshal
> does not work. None of the properties of user are set.
>
> I'm missing something in my understanding of json support. What am I
> missing?
The json package don't see the fields on your User type because
they're not exported.
The field names need to start with an uppercase letter and have a name
that matches the name in the object you're unmarshalling.
If the object you're unmarshalling has lowercase field names then
you'll need to add struct field tags to your User struct fields.
eg.
type User struct {
Name string `json:"name"`
EmailAddress string `json:"emailAddress"`
Password string `json:"password"`
UserId string `json:"userid"`
}