我有一串json[{"id":1},{"id":2}....] 试图定义为struct
```go
type A struct {
Nodes []Node `json:"node"`
}
type Node struct {
Id string `json:"id"`
}
```
可是无法转化 请问 这struct应该如何定义
更多评论
Id string
应该是id int
json也是有类型的
然后,你json里没有node 。
按你的范例,应该是
type A []Node
#2
理解了 感谢大家
我这里直接定义了一个NODE 就能把数组插入了
type Node struct {
Id int
}
然后直接解析了
#3