It appears that until go 1.8 releases, float64 values with six places of 
precision will always be output in scientific notation when sent through 
json.Marshal().

This recently fixed issue explains this: 
https://github.com/golang/go/issues/6384#issuecomment-261140529 

In short, encoding float64 values with six decimal places or more causes 
them to be output in scientific notation like this: 1.4e-05

So my question is: Prior to go 1.8's release, how can we force float64 
values to be output in decimal?  This is a problem for me specifically 
because our mobile user's report their lat/lon with six places of 
precision.  Trying to dump that output to JSON causes a bunch of unusable 
scientific notation in the output.

I know that you can implement a MarshalJSON method, but that only really 
allows me to customize what happens before json.Marshal is called.  No 
matter what I've tried, it still mangles the output.  The only solution I 
see is using another package or writing a custom []byte parser to go fix 
the bad []byte returned from the marshaling.

Anyone got ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to