Skip to main content
DevTools24

JSON 转 Go 结构体

从 JSON 数据生成 Go 结构体定义。处理嵌套对象、数组和正确的 json 标签。

Features:
  • • Converts JSON to Go struct definitions
  • • Handles nested objects and arrays
  • • Generates proper json tags
  • • Converts snake_case to PascalCase
  • • Optional omitempty and pointer types

Go Structs - 技术详情

Go structs with json tags enable seamless JSON marshaling and unmarshaling. Field names are converted to PascalCase while json tags preserve the original JSON keys.

命令行替代方案

# Using json-to-go CLI
go install github.com/mholt/json-to-go/cmd/json-to-go@latest
echo '{"name":"test"}' | json-to-go

参考

查看官方规范