Skip to main content

PyPI PyPI - Python Version PyPI - Wheel Tests

FuJSON: less decimals, more fuzzy JSON

FuJSON is a Python module that allows to control the formatting of floats when JSON encoding, typically to dial down the number of decimals.

It builds on the standard library's json.JSONEncoder and monkey-patches it to inject custom float formatting.

Usage

Simple dumps call:

>>> from fujson import dumps
>>> dumps({"x": 1.23456789}, float_format=".2f")
'{"x": 1.23}'

Reusable encoder:

>>> from fujson import FuJsonEncoder
>>> encoder = FuJsonEncoder(float_format=".2f")
>>> encoder.encode({"x": 1.23456789})
'{"x": 1.23}'
>>> encoder.encode([1.1, 2.22, 3.333, 4.4444])
'[1.10, 2.22, 3.33, 4.44]'

Do JSON dump with floats in scientific notation:

>>> from fujson import FuJsonEncoder
>>> encoder = FuJsonEncoder(float_format=".2e")
>>> encoder.encode([.123, 0.0000123, 12345678.9])
'[1.23e-01, 1.23e-05, 1.23e+07]'

Metadata

Release files for fujson 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fujson 0.1.2
File Size Uploaded Provenance
fujson-0.1.2.tar.gz 2.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fujson 0.1.2
File Interpreter ABI Platform
fujson-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.2 kB

Release files / fujson-0.1.2.tar.gz

Download URL fujson-0.1.2.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
685fbfab83ce6f6460236978837b1c264e9a374f1b686d20dd5c8fad7c2082d4
BLAKE2b-256 checksum
How to use checksums
06242c41810eb296e323c228b955c4132eb3a8a5b458377546c09634ab59db8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / fujson-0.1.2-py3-none-any.whl

Download URL fujson-0.1.2-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8a0a951003bacd69ca889ba38ce0e7f0f44938c557936ff85bf1387bb042cc7
BLAKE2b-256 checksum
How to use checksums
b88841473944c713fab18ae1beb3ec2c5a0c482c93f164f6492bf041d836a811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for fujson 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page