golang 加载jison而无需定义一堆结构体
jsonName := filenameOnly + ".json"
fmt.Println("fileSuffix = ", fileSuffix)
fmt.Println("jsonName = ", jsonName)
jsonPath := subDirPath + jsonName
bytes, err := ioutil.ReadFile(jsonPath)
if err != nil {
fmt.Println("读取json文件失败", err)
return nil
}
jsonDt3, err := simplejson.NewJson(bytes) //反序列化
if err != nil {
panic(err.Error())
}
var nodes = make(map[string]interface{})
nodes, _ = jsonDt3.Map()
fmt.Println("jsonDt3 = ", jsonDt3)
fmt.Println("nodes = ", nodes)
fmt.Println("nodes.file = ", nodes["file"])
fmt.Println("nodes.file = ", nodes["frames"])
for key, _ := range nodes {
fmt.Println(nodes[key])
}
网友评论