假设我有这样的json:
{
"a": [
[
"aaa",
15
],
[
"bbb",
11
]
]
}
我有这个代码:
func main() {
XJson := `
{
"a": [
[
"aaa",
15
],
[
"bbb",
11
]
]
}`
var Output StructJson
json.Unmarshal([]byte(XJson), &Output)
fmt.Println(Output)
}
type StructJson struct {
[][]string `json:"a"` //wrong because have 15 and 11 have int type data
///what must i do in here?
}
如何解组?我的意思是,“aaa”和“bbb”具有数据字符串类型,15 和 11 具有数据整数类型。如果我使用那个“错误”的结构,输出是
{[[aaa ] [bbb ]]}
智慧大石
相关分类