https://github.com/nschloe/fjson
Python JSON writer with formatted floats
https://github.com/nschloe/fjson
json python
Last synced: 11 months ago
JSON representation
Python JSON writer with formatted floats
- Host: GitHub
- URL: https://github.com/nschloe/fjson
- Owner: nschloe
- License: other
- Created: 2020-07-24T17:03:19.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2022-11-30T10:59:32.000Z (over 3 years ago)
- Last Synced: 2025-07-02T18:45:55.144Z (12 months ago)
- Topics: json, python
- Language: Python
- Homepage:
- Size: 68.4 KB
- Stars: 14
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
JSON with float formatting.
[](https://pypi.org/project/fjson)
[](https://pypi.org/pypi/fjson/)
[](https://github.com/nschloe/fjson)
[](https://pepy.tech/project/fjson)
[](https://github.com/nschloe/fjson/actions?query=workflow%3Aci)
[](https://codecov.io/gh/nschloe/fjson)
[](https://github.com/psf/black)
The [json](https://docs.python.org/3/library/json.html) 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.
```python
import math
import fjson
data = {"a": 1, "b": math.pi}
string = fjson.dumps(data, float_format=".6e", indent=2, separators=(", ", ": "))
print(string)
```
```json
{
"a": 1,
"b": 3.141593e+00
}
```
### License
fjson is published under the [MIT license](https://en.wikipedia.org/wiki/MIT_License).