I have parsed a large amount of json, manipulated some values and I'd like to write it back out. Aeson decodes numbers into scientific, but when it encodes it, by default, scientific shows numbers in scientific notation in many cases, and aeson does not offer any means that I can see to change that.
> decode "[\"asdf\", 1, 1.0, 1000000000.1, 0.01]" :: Maybe Value
Just (Array [String "asdf",Number 1.0,Number 1.0,Number 1.0000000001e9,Number 1.0e-2])
encode (Array [String "asdf",Number 1.0,Number 1.0,Number 1.0000000001e9,Number 1.0e-2])
"[\"asdf\",1,1,1.0000000001e9,1.0e-2]"
> encode (Array [String "asdf", Number 1, Number 1.0, Number 1000000000.1, Number 0.01])
"[\"asdf\",1,1,1.0000000001e9,1.0e-2]"
How can I write out my Value with numbers in a more widely acceptable format that other languages can consume? Let's pretend I'm not concerned with precision loss or integer overflows. The scientific package has the means to format numbers in this manner, aeson just happened not to use it.
>formatScientific Fixed Nothing (0.01)
"0.01"
>formatScientific Fixed Nothing (1000000000.1)
"1000000000.1"