Documentation
¶
Index ¶
- Variables
- func CompareNumberType(type1, type2 string) string
- func ParseType(t json.Token) (string, string)
- func Regularize(name string) string
- func Replace(s string, pattern *regexp.Regexp, ...) string
- func ToPascalCase(name string) string
- func Unmarshal(data []byte, name string) ([]byte, error)
- func UnmarshalAPI(api req.API) error
- type Converter
Constants ¶
This section is empty.
Variables ¶
View Source
var Abbreviation = map[string]bool{ "API": true, "ASCII": true, "CPU": true, "CSS": true, "DNS": true, "EOF": true, "GUID": true, "HTML": true, "HTTP": true, "HTTPS": true, "ID": true, "IP": true, "JSON": true, "LHS": true, "QPS": true, "RAM": true, "RHS": true, "RPC": true, "SLA": true, "SMTP": true, "SSH": true, "TCP": true, "TLS": true, "TTL": true, "UDP": true, "UI": true, "UID": true, "UUID": true, "URI": true, "URL": true, "UTF8": true, "VM": true, "XML": true, "XSRF": true, "XSS": true, }
Abbreviation 是需要保持全大写的缩写词的映射,值为真时生效
View Source
var DefaultConverter = &Converter{}
View Source
var ErrInvalidDelim = errors.New("jsontogo: invalid delim")
View Source
var ErrInvalidToken = errors.New("jsontogo: invalid token")
Functions ¶
func CompareNumberType ¶
CompareNumberType 用于比较两个类型名,当任一类型不为浮点数或整数时返回 `any` ,否则返回范围更大的类型名
func Replace ¶
func Replace(s string, pattern *regexp.Regexp, fn func(match string, submatch []string) string) string
Replace 用正则表达式对字符串匹配和替换,用法与 JavaScript 中的替换函数类似
func ToPascalCase ¶
ToPascalCase 将字段名称转换为驼峰命名,会保持缩写词全大写并且移除所有非字母数字的字符
func UnmarshalAPI ¶
Types ¶
type Converter ¶
type Converter struct {
// 是否使用 interface{}
UseInterface bool
// 是否在字段后加注释
AddComment bool
// contains filtered or unexported fields
}
Converter 转换器,用于将 JSON 文本转换为能接收其值的结构体
func (*Converter) UnmarshalJSON ¶
UnmarshalJSON 反序列化 JSON
Click to show internal directories.
Click to hide internal directories.