我有一個示例 json 文件,其結(jié)構(gòu)如下{ "method":"brute_force", "bc":"select * from blah;", "gc":[ "select sum(year) from blah;", "select count(*) from table;" ]}我正在嘗試編寫一個可以讀取此文件并操作 json 內(nèi)容的 go 程序。package main import ( "fmt" "encoding/json" "io/ioutil" )type Response2 struct { method string bc string gc []string}func main() { file,_ := ioutil.ReadFile("config.json") fmt.Printf("%s",string(file)) res := &Response2{} json.Unmarshal([]byte(string(file)), &res) fmt.Println(res) fmt.Println(res.method) fmt.Println(res.gc)}res.method 和 res.gc 不打印任何東西。我不知道出了什么問題。
- 1 回答
- 0 關(guān)注
- 308 瀏覽
添加回答
舉報
0/150
提交
取消