我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在Go中封送[] interface {}

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?

Put arrays in double quotes json:"arrays"

近期文章

  • 在go lang中使用exec.command进行网络使用
  • 如何安装libvirt-go? (pkg配置)
  • Golang UDP和TCP彼此并排
  • 类型声明的位置
  • 将值和切片存储在地图中
  • 走文件路径。步行行为
  • 如何定义静态成员函数?
  • 如何在golang中的嵌套结构范围内?
  • Panic()与struct vs指针的含义?
  • 如何在go中表达C ++逻辑的“新”运算符?
  • 如何在Golang中将接口{}转换为嵌套树
  • 如何从快照ID获取卷ID?
  • 一个goroutine从结构读取而另一个goroutine对其进行修改是否安全?
  • 如何获取Windows应用程序的位置和区域(例如“ Google Chrome”)? [关闭]
  • 如何在Go中的HTML文件中添加图像
  • 范围超过JSON数组时无法迭代所有索引
  • 去:随机终止kubernetes集群中的Pod
  • 为什么在传输多个文件时WebSocket的实现要比HTTP / 2推送慢? (Node.js / Go)
  • RSA在Java和Go之间进行加密和解密
  • golang编译错误:找不到导入

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华