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

x/blog: some more details in /json section #40427

Closed
ja8zyjits opened this issue Jul 27, 2020 · 2 comments
Closed

x/blog: some more details in /json section #40427

ja8zyjits opened this issue Jul 27, 2020 · 2 comments

Comments

@ja8zyjits
Copy link

What did you expect to see?

Iam from Python background and hence it was little bit difficult for me to understand how unmarshalling works, specially if the keywords are lowercase

The https://blog.golang.org/json blog appears in the top of the search while searching for json.

There is this line
The json package only accesses the exported fields of struct types (those that begin with an uppercase letter). Therefore only the the exported fields of a struct will be present in the JSON output.

It would be great if we could also add an example saying
If your json has lowercase keys, then you might have to follow the below snippet to access them. For further information check out https://golang.org/pkg/encoding/json/#Marshal

type Message struct {
    Name string `json:”name”
    Body string   `json:”bodyTime int64    `json:”time”
}

What did you see instead?

The example stops with the
The json package only accesses the exported fields of struct types (those that begin with an uppercase letter). Therefore only the the exported fields of a struct will be present in the JSON output.
This makes it bit difficult for new comers to easily understand the techniques that are very trivial.

I would be happy to submit PR, but I dont know where the docs of blog are.

@gopherbot gopherbot added this to the Unreleased milestone Jul 27, 2020
@ianlancetaylor
Copy link
Contributor

The blog is in the repo golang.org/x/blog which is mirrored to github.com/golang/blog.

@ja8zyjits
Copy link
Author

ja8zyjits commented Jul 28, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants