go 结构体 json对象这种类型如何定义

go 结构体 [{“value”:”\u91d1\u989d”,”key”:3,”name”:”price”,”text”:null,”type”:1}] 这种类型如何定义

本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 8
A{
value
}
B{
 As []A
}

json数据解析到b,注意具体的其他数据自己填

1年前 评论
lijizheng (楼主) 1年前
deatil (作者) 1年前
type A struct {
    Value string      `json:"value"`
    Key   int         `json:"key"`
    Name  string      `json:"name"`
    Text  interface{} `json:"text"`
    Type  int         `json:"type"`
}

type B struct {
    Value string `json:"value"`
    Data  []A    `json:"data"`
}
1年前 评论
type Data []struct {
    Value string `json:"value"`
    Key string `json:"key"`
    Name string `json:"name"`
    Text string `json:"text"`
    Type string `json:"type"`
}
1年前 评论

在这个网站直接复制json生产结构体 mholt.github.io/json-to-go/

1年前 评论

@Breezess 这个工具好,万分感谢

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!