Fix some md err

This commit is contained in:
vCaesar
2017-06-06 21:50:50 +08:00
parent ceb9768171
commit 02d5d51463
2 changed files with 6 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ Suppose we have the JSON in the above example. How can we parse this data and ma
func Unmarshal(data []byte, v interface{}) error
```
We can use this function like so:
```Go
package main
@@ -69,12 +70,12 @@ Suppose we have the following JSON data:
b := []byte(`{"Name":"Wednesday","Age":6,"Parents":["Gomez","Morticia"]}`)
```
Now we parse this JSON to an interface{}:
```Go`
```Go
var f interface{}
err := json.Unmarshal(b, &f)
```
The `f` stores a map, where keys are strings and values are interface{}'s'.
```Go`
```Go
f = map[string]interface{}{
"Name": "Wednesday",
"Age": 6,
@@ -85,7 +86,7 @@ The `f` stores a map, where keys are strings and values are interface{}'s'.
}
```
So, how do we access this data? Type assertion.
```Go`
```Go
m := f.(map[string]interface{})
```
After asserted, you can use the following code to access data:

View File

@@ -103,9 +103,9 @@ The following functions are from the `strconv` package. As usual, please see off
str = strconv.AppendQuoteRune(str, '单')
fmt.Println(string(str))
}
```
- Format series, convert other data types into string.
```Go
package main
import (