diff --git a/en/07.2.md b/en/07.2.md index 8559c49c..e77a9904 100644 --- a/en/07.2.md +++ b/en/07.2.md @@ -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: diff --git a/en/07.6.md b/en/07.6.md index 66f92979..a7d1cfca 100644 --- a/en/07.6.md +++ b/en/07.6.md @@ -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 (