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 struc

[go-nuts] json.number in struct

2020-11-01 Thread irvan hendrik
Hi, I have type Product struct { Weight json.Number } func (p Product) GetWeight() float64 { tmp, _ := p.Weight.Float64() return tmp } I would like to be able to call and assign the variable directly. I got the GetWeight() to help me convert from json.Number to float64. How to assign the varia