mholt / json-to-go

Translates JSON into a Go type in your browser instantly (original)
https://mholt.github.io/json-to-go/
MIT License
4.5k stars 474 forks source link

Name like PM1.0 gets "translated" into PM1.1. #63

Closed forgerock1 closed 4 years ago

forgerock1 commented 5 years ago

Hi. Thanks for the tool, this is a great thing to avoid typos and reduce efforts. I found an issue when using it, here the example:

JSON:

{
    "ts": 1554294203,
    "tem": 19.30,
    "hum": 47.70,
    "PM1.0": 0,
    "PM2.5": 0,
    "PM10.": 0,
    "P0.3": 48,
    "P0.5": 16,
    "P1.0": 2,
    "P2.5": 0,
    "P5.0": 0,
    "P10.": 0
}

Produces:

type AutoGenerated struct {
    Ts   int     `json:"ts"`
    Tem  float64 `json:"tem"`
    Hum  float64 `json:"hum"`
    PM11 int     `json:"PM1.1"`
    PM25 int     `json:"PM2.5"`
    PM10 int     `json:"PM10."`
    P03  int     `json:"P0.3"`
    P05  int     `json:"P0.5"`
    P11  int     `json:"P1.1"`
    P25  int     `json:"P2.5"`
    P51  int     `json:"P5.1"`
    P10  int     `json:"P10."`
}

Where as you can see the PM1.0 , P1.0 and P5.0 get a wrong name

Regards,

mholt commented 4 years ago

That is peculiar... thanks for the report!