update from sparkleup

This commit is contained in:
Madison Scott-Clary 2022-06-23 09:55:06 -07:00
parent 957547cbe3
commit b7f8a85ee9
2 changed files with 3 additions and 2 deletions

View File

@ -66,7 +66,7 @@ JavaScript Object Notation (JSON) is a textual format for encoding collections o
This JSON object contains two keys, `language` and `mascot`. Following these keys are the associated values. Here the `language` key has a value of `Go` and `mascot` is assigned the value `Gopher`.
The JSON encoder in the standard library makes use of struct tags as annotations indicating to the encoder how you would like to name your fields in the JSON output. These JSON encoding and decoding mechanisms can be found in the `encoding/json` [package](https://godoc.org/encoding/json).
The JSON encoder in the standard library makes use of struct tags as annotations indicating to the encoder how you would like to name your fields in the JSON output. These JSON encoding and decoding mechanisms can be found in the `encoding/json` [package](https://pkg.go.dev/encoding/json).
Try this example to see how JSON is encoded without struct tags:
@ -327,7 +327,7 @@ When you run this example, you'll see this output:
The only thing we've changed in this example from previous ones is that the password field now uses the special `"-"` value for its `json:` struct tag. In the output from this example that the `password` field is no longer present.
These features of the `encoding/json` package, `,omitempty` and `"-"`, are not standards. What a package decides to do with values of a struct tag depends on its implementation. Because the `encoding/json` package is part of the standard library, other packages have also implemented these features in the same way as a matter of convention. However, it's important to read the documentation for any third-party package that uses struct tags to learn what is supported and what is not.
These features of the `encoding/json` package`,omitempty`, `"-"`, and [other options](https://pkg.go.dev/encoding/json#Marshal) — are not standards. What a package decides to do with values of a struct tag depends on its implementation. Because the `encoding/json` package is part of the standard library, other packages have also implemented these features in the same way as a matter of convention. However, it's important to read the documentation for any third-party package that uses struct tags to learn what is supported and what is not.
## Conclusion

View File

@ -4,5 +4,6 @@
* [How to create temporary and permanent redirects with nginx](ctm-407)
* [How to configure Nginx with SSL as a reverse proxy for Jenkins](ctm-385)
* [How to Access Elements in the DOM](ctm-406)
* [How to Use Struct Tags in Go](ctm-514)
## New