Skip to content

Commit

Permalink
Update text and output of json example slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Dec 30, 2024
1 parent 7951241 commit 58894bd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ func main() {
d := map[string]int{"apple": 5, "lettuce": 7}
enc.Encode(d)

// We can also decode JSON directly from `os.Reader`
// Streaming reads from `os.Reader`s like `os.Stdin`
// or HTTP request bodies is done with `json.Decoder`.
dec := json.NewDecoder(strings.NewReader(str))
res1 := response2{}
dec.Decode(&res1)
fmt.Println(res1)
fmt.Println(res1.Fruits[1])
}
4 changes: 2 additions & 2 deletions examples/json/json.hash
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
75a5664321dafe10fa623c187b90f079c5319a3c
jR7IEUPQF8T
db25fb3a8b52215441ebe0a5d6a4d4f1a8be5917
zwf9dZ4pUPW
1 change: 1 addition & 0 deletions examples/json/json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ a
{1 [apple peach]}
apple
{"apple":5,"lettuce":7}
{1 [apple peach]}


# We've covered the basic of JSON in Go here, but check
Expand Down
11 changes: 6 additions & 5 deletions public/json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58894bd

Please sign in to comment.