Skip to content
Advertisement

Tag: json

Format floats with standard json module

I am using the standard json module in python 2.6 to serialize a list of floats. However, I’m getting results like this: I want the floats to be formated with only two decimal digits. The output should look like this: I have tried defining my own JSON Encoder class: This works for a sole float object: But fails for nested

Advertisement