Documentation
¶
Overview ¶
Package jy2struct is a library for generating go struct code, supporting json and yaml.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ForceFloats bool
ForceFloats whether to force a change to float
Functions ¶
func Convert ¶
Convert 将 JSON 或 YAML 内容转换为 Go 结构体代码
优先使用 Data 字段的内容,如果 Data 为空则从 InputFile 读取文件。
参数:
args - 转换参数,包含格式、数据源、结构体名称等配置
返回值:
string - 生成的 Go 结构体代码 error - 如果参数校验失败、文件读取失败或转换失败则返回错误
func FmtFieldName ¶
FmtFieldName formats a string as a struct key
Example:
FmtFieldName("foo_id")
Output: FooID
Types ¶
type Args ¶
type Args struct {
Format string
Data string
InputFile string
Name string
SubStruct bool
Tags string
// contains filtered or unexported fields
}
Args 转换参数,定义输入格式、内容和输出结构体名称
字段说明:
Format - 文档格式,支持 "json" 或 "yaml" Data - JSON 或 YAML 内容(与 InputFile 二选一) InputFile - 输入文件路径(与 Data 二选一) Name - 生成的根结构体名称 SubStruct - 是否将子结构分离为独立结构体 Tags - 额外的标签,多个标签用逗号分隔
Click to show internal directories.
Click to hide internal directories.