JSON with float formatting.
The json module in the Python standard
library does not allow you to specify the format in which float
s are written out the
file. This module adds the float_format
parameter.
import math
import fjson
data = {"a": 1, "b": math.pi}
string = fjson.dumps(data, float_format=".6e", indent=2, separators=(", ", ": "))
print(string)
{
"a": 1,
"b": 3.141593e+00
}
fjson is published under the MIT license.