Skip to content

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

@lhlyu

Description

@lhlyu
{
    "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"`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions