json-to-go
json-to-go copied to clipboard
对于key是数字类型的转换思考
{
"a": -1231.323,
"b": {
"z": 31,
"p": true,
"123": "key是字符串"
}
}
下面哪种转换比较合理呢......
type RootObject struct {
A float64 `json:"a"`
B map[string]interface{} `json:"b"`
}
type RootObject struct {
A float64 `json:"a"`
B B `json:"b"`
}
type B struct {
Z int `json:"z"`
P bool `json:"p"`
NumberField string `json:"123"`
}