Skip to main content

Module pyjson

Module pyjson 

Source
Expand description

Python’s json.dumps, byte for byte, for the values a request can hold.

Laya renders structured states, criteria and instructions with json.dumps, and the compat models were trained on exactly that text. A different float spelling (1e-5 against Python’s 1e-05) or a different escape (\u00e9 against é) changes the token ids, so this writer copies Python’s choices rather than serde_json’s.

Integers larger than u64 arrive from serde_json as floats and print as floats, where Python would print them exactly. No real request has hit that yet.

Structs§

Dumps
The options Laya uses. Every call site in Laya keeps Python’s default separators, ", " and ": ", so only ensure_ascii varies.

Functions§

float_repr
Python’s repr(float): the shortest digits that round trip, in fixed notation when the decimal exponent is from -4 to 15 and in scientific notation otherwise, with a sign and at least two exponent digits. Integral values keep a .0.