JSON转Go Struct
将JSON数据转换为Go语言结构体
工具说明
此工具可以将JSON数据转换为Go语言结构体,支持自定义结构体名称、标签选项、字段类型推断等功能。生成的代码可以直接复制到Go项目中使用,大大提高开发效率。
使用场景
- API开发中快速生成请求/响应结构体
- 解析JSON配置文件时生成对应结构体
- 学习Go语言结构体定义
- 批量处理JSON数据时使用
示例JSON
用户信息
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"age": 30,
"isActive": true,
"roles": ["admin", "user"],
"address": {
"street": "123 Main St",
"city": "New York",
"zipCode": "10001"
}
}API响应
{
"success": true,
"data": {
"items": [
{
"id": "123",
"title": "Product 1",
"price": 99.99
}
],
"total": 1,
"page": 1,
"pageSize": 10
},
"error": null,
"timestamp": 1634567890
}