Closed CHN-STUDENT closed 3 years ago
It is a default behaviour even in encoding/json library since it treats float64 and int as JSON numbers. Read here https://golang.org/pkg/encoding/json/#Unmarshal
To keep decimal intact, you can define your own type for float and implement MarshalJSON method on that type.
@bytegaurav ok. thanks! i define my own type json date to solve it. Glad to get your help!
eg
Expected value:
{ "CPU": 12.0 }
Actual value:
{ "CPU": 12 }
I do not hope automatically omit decimals my float64 value, so could you tell me how to solve it? Thanks!