在Go语言中,将[]interface{}进行编组

huangapple go评论68阅读模式
英文:

Marshaling []interface{} in Go

问题

这是将接口数组进行编组的正确方式吗?

英文:
type A struct {
    Id   uint32 `json:"id"`
}

type B struct {
    A
    Title           string `json:"title"`
}

type C struct {
    Id             uint32 `json:"id"`
    Name           string `json:"name"`
    Arrays         []interface{} `json:"arrays"`
}

Is this the correct way to marshal an array of interfaces?

答案1

得分: 1

将数组放在双引号中的 JSON 表示为:"arrays"

英文:

Put arrays in double quotes json:"arrays"

huangapple
  • 本文由 发表于 2017年5月6日 00:36:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/43809908.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定