Skip to content
/ fjson Public

Python JSON writer with formatted floats

License

Notifications You must be signed in to change notification settings

nschloe/fjson

Repository files navigation

fjson

JSON with float formatting.

PyPi Version PyPI pyversions GitHub stars Downloads

gh-actions codecov Code style: black

The json module in the Python standard library does not allow you to specify the format in which floats 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
}

License

fjson is published under the MIT license.

About

Python JSON writer with formatted floats

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages