Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于key是数字类型的转换思考 #12

Open
lhlyu opened this issue Sep 24, 2021 · 0 comments
Open

对于key是数字类型的转换思考 #12

lhlyu opened this issue Sep 24, 2021 · 0 comments
Labels
improve 改进

Comments

@lhlyu
Copy link
Member

lhlyu commented Sep 24, 2021

{
    "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"`
}
@lhlyu lhlyu added the improve 改进 label Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve 改进
Projects
None yet
Development

No branches or pull requests

1 participant