My JSON looks like this:
{
"website": {
"id": 8,
"account_id": 9,
"name": "max",
"website_url": "",
"subscription_status": "trial",
"created_at": "2016-01-24T01:43:41.693Z",
"updated_at": "2016-02-21T01:17:53.129Z",
}
}
My Website struct looks like this:
type Website struct {
Id int64 `json:"id"`
AccountId int64 `json:"account_id"`
Name string `json:"name"`
WebsiteUrl string `json:"website_url"`
SubscriptionStatus string `json:"subscription_status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
I then have a Company struct like:
type Company struct {
Website Website
api *API
}
So in my API client code I have this:
res, status, err := api.request(endpoint, "GET", nil, nil)
if err != nil {
return nil, err
}
if status != 200 {
return nil, fmt.Errorf("Status returned: %d", status)
}
r := map[string]Company{}
err = json.NewDecoder(res).Decode(&r)
fmt.Printf("things are: %v
", r)
The output I am getting is this:
things are: map[website:{{0 0 0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC} <nil>}]
How can I debug this, I am not sure why it is not setting the Website struct with correct values.
Update
I added this, I don't see any output:
if err != nil {
fmt.Printf("error is not nillllllll!!!:")
fmt.Println(err)
return nil, err
}