有这个json文件: { "colors": [ ["#7ad9ab", "#5ebd90", "#41a277", "#21875e", "#713517"], ["#5ebd90", "#41a277", "#21875e", "#006d46", "#561e00"], ["#005430"] ]}这段代码:type Palette struct { Colors []string}func TestStuff(t *testing.T) { c, err := os.Open("palette.json") if err != nil { fmt.Printf("Error: %v", err.Error()) } defer c.Close() bc, _ := ioutil.ReadAll(c) var palette []Palette //also tried with Palette err = json.Unmarshal(bc, &palette) if err != nil { fmt.Printf("Error: %v \n", err.Error()) } fmt.Printf("Data: %v", palette)}并不断得到:错误:json:无法将数组解组到Go结构字段Palette中。字符串类型的颜色或类似,如果我更改调色板类型。尖端?谢谢!
2 回答
- 2 回答
- 0 关注
- 219 浏览
添加回答
举报
0/150
提交
取消