
The current example shows `json.Unmarshal` on an array of bytes, including `num:6.0`. In the output however this comes out as `6`. Even in the casting to `float64`, it comes out as `6`. This can be confusion because it looks like a simple `int`. By adding an arbitray `.13` you see it's a float.
22 lines
475 B
Bash
22 lines
475 B
Bash
$ go run json.go
|
|
true
|
|
1
|
|
2.34
|
|
"gopher"
|
|
["apple","peach","pear"]
|
|
{"apple":5,"lettuce":7}
|
|
{"Page":1,"Fruits":["apple","peach","pear"]}
|
|
{"page":1,"fruits":["apple","peach","pear"]}
|
|
map[num:6.13 strs:[a b]]
|
|
6.13
|
|
a
|
|
&{1 [apple peach]}
|
|
apple
|
|
{"apple":5,"lettuce":7}
|
|
|
|
|
|
# We've covered the basic of JSON in Go here, but check
|
|
# out the [JSON and Go](http://blog.golang.org/2011/01/json-and-go.html)
|
|
# blog post and [JSON package docs](http://golang.org/pkg/encoding/json/)
|
|
# for more.
|