JSON转Go

将JSON数据自动转换为Go语言结构体定义

JSON输入

Go结构体


        

转换选项

JSON字符数

0

结构体字段数

0

生成代码行数

0

使用示例

JSON输入:

{
  "name": "JSON转Go工具",
  "version": "1.0.0",
  "description": "将JSON数据转换为Go结构体",
  "features": [
    "JSON语法验证",
    "一键转换",
    "结果复制"
  ],
  "settings": {
    "indentation": 2,
    "export": true
  },
  "stats": {
    "conversionCount": 1000,
    "averageTimeMs": 15.2
  }
}

Go结构体输出:

type Root struct {
    Name        string  `json:"name,omitempty"`
    Version     string  `json:"version,omitempty"`
    Description string  `json:"description,omitempty"`
    Features    []string `json:"features,omitempty"`
    Settings    Settings `json:"settings,omitempty"`
    Stats       Stats    `json:"stats,omitempty"`
}

type Settings struct {
    Indentation int `json:"indentation,omitempty"`
    Export      bool `json:"export,omitempty"`
}

type Stats struct {
    ConversionCount int     `json:"conversionCount,omitempty"`
    AverageTimeMs  float64 `json:"averageTimeMs,omitempty"`
}