Created
October 28, 2018 10:46
-
-
Save bwangelme/5a51a3b857709dd8c475260068419740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"log" | |
"reflect" | |
) | |
func main() { | |
var val map[string]interface{} | |
err := json.Unmarshal([]byte(`{"v":1}`), &val) | |
if err != nil { | |
log.Fatalln(err) | |
} | |
// 注意 json.Unmarshal 解析到map中,数字会默认处理成 float64 | |
fmt.Println(val, reflect.TypeOf(val["v"])) | |
// map[v:1] float64 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment