Skip to main content

Module pyjson

Module pyjson 

Source
Expand description

json.dumps the way CPython writes it, so files and stdout compare byte for byte with the Python pipeline.

Covers what the pipeline uses: indent=2 and compact form, ensure_ascii on and off, Python float repr, insertion-ordered objects (serde_json is built with preserve_order).

Structs§

Style
How to render.

Constants§

RAW_MARKER
Marker prefix for a value that must be emitted verbatim, unquoted.

Functions§

dumps
Serialize v in the given style. Never fails: every Value is representable.
float_repr
repr(float): shortest round-trip digits, fixed notation when the decimal exponent is in -4..16, otherwise d.ddde±XX with a two-digit minimum exponent. Integral values keep a .0.
newline 🔒
Between items: a newline plus indentation when indenting, a single space after the comma in compact mode (Python’s default ", " separator).
py_float
Wrap a float the way Python’s json module would write it: an ordinary number when finite, a bare token when not.
write_string
Python’s string escaping: " \ and the C escapes, other control characters as \u00XX; with ensure_ascii, everything above U+007F as \uXXXX (surrogate pairs beyond the BMP). / is never escaped.
write_value 🔒