Re: [go-nuts] Re: json.number in struct

2020-11-04 Thread Urjit Singh Bhatia
Yeah, iirc JSON doesn't really have a clear distinction between float and int because it has to sort of stay parallel to javascript. Found this link that explains a bit more... Excerpt: ```The precise treatment of the “integer” type may depend on the implementation of your JSON Schema

Re: [go-nuts] Re: json.number in struct

2020-11-02 Thread Jan Mercl
On Mon, Nov 2, 2020 at 12:30 PM irvan hendrik wrote: > yes. because when I marshal it to json the number got messed up. > when I entered value 10.0 it became 10. > If I use json.number it keeps the format 10.0. Sounds like conflating data and their representation. I'm not a json expert, but

Re: [go-nuts] Re: json.number in struct

2020-11-02 Thread irvan hendrik
yes. because when I marshal it to json the number got messed up. when I entered value 10.0 it became 10. If I use json.number it keeps the format 10.0. Regards. On Mon, Nov 2, 2020 at 2:46 PM Brian Candler wrote: > Is there a particular reason why you don't just do this? > > type Product

[go-nuts] Re: json.number in struct

2020-11-01 Thread Brian Candler
Is there a particular reason why you don't just do this? type Product struct { Weight float64 } That should serialize to/from JSON just fine. You can also include metadata about how you want it serialized: type Product struct { Weight float64 `json:"weight,omitempty"` } -- You