Skip to content
New issue

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

Define types for array elements #46

Open
ChimeraCoder opened this issue Jun 18, 2017 · 0 comments
Open

Define types for array elements #46

ChimeraCoder opened this issue Jun 18, 2017 · 0 comments

Comments

@ChimeraCoder
Copy link
Owner

This came up in ChimeraCoder/anaconda#187.

[
  {
    "id": "1",
    "url": "https://united.fr/webhook",
    "valid": true,
    "created_timestamp": "134325325301"
  }
]

will create

type Foo []struct {
	CreatedTimestamp string `json:"created_timestamp"`
	ID               string `json:"id"`
	URL              string `json:"url"`
	Valid            bool   `json:"valid"`
}

but in reality, most of the time, this is more convenient:

type Foo struct {
	CreatedTimestamp string `json:"created_timestamp"`
	ID               string `json:"id"`
	URL              string `json:"url"`
	Valid            bool   `json:"valid"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant