org.pycforge.json · Author: PyCForge
License: GPL-3.0-only · Created: 2026-10-31
Runtime conversion · Direct declared calls
A bounded standard JSON conversion package for Runtime data exchange.
Select Runtime and declare *import json. Read text with json.loads(text), then serialize with json.dumps(value). Use ensure_ascii=False for Unicode output or separators=(",", ":") for compact text.
Runtime JSON values: None, bool, signed int64, finite float64, Unicode-scalar strings, lists/tuples and dictionaries with string keys. loads accepts str only and produces lists for JSON arrays. Duplicate object names keep their first position and last value. dumps preserves dictionary insertion order and encodes tuples as arrays. ensure_ascii is a bool, default True; separators is None or a pair of strings. Defaults match compact single-line Python JSON spacing. No hooks, subclasses, custom encoders, bytes, streams, indent, sort_keys, NaN/Infinity, arbitrary-precision integers or lone surrogates. At most 64 nested containers, 1 MiB UTF-8 input/output, and 1024 bytes per numeric token. Malformed text, unsupported values, cycles and profile limits raise catchable errors; syntax errors are ValueError without JSONDecodeError attributes. Allocation/work exhaustion is fatal under the Runtime policy. Float parsing requires a C-compatible numeric locale and nearest rounding. Inputs are never mutated or retained. Failed operations release their partial allocations. Returned values belong to their originating Runtime context and require live roots at collection boundaries. Generated C needs no Python runtime or external JSON library.
Initial structured-value profile with loads/dumps, Unicode escapes, finite int64/float64 values, ordered dictionaries, cycle detection and explicit resource limits.
Examples are author-supplied fixture snapshots. The SDK reports verification for its recorded environment; PyCForge registration does not rerun them.
Use *import json in the module preamble. Each signature states accepted positions, names and defaults. A slash marks positional-only parameters; a star marks keyword-only parameters. Argument expansion, function values and Typed conversion are unsupported.
Runtime JSON values: None, bool, signed int64, finite float64, Unicode-scalar strings, lists/tuples and dictionaries with string keys. loads accepts str only and produces lists for JSON arrays. Duplicate object names keep their first position and last value. dumps preserves dictionary insertion order and encodes tuples as arrays. ensure_ascii is a bool, default True; separators is None or a pair of strings. Defaults match compact single-line Python JSON spacing. No hooks, subclasses, custom encoders, bytes, streams, indent, sort_keys, NaN/Infinity, arbitrary-precision integers or lone surrogates. At most 64 nested containers, 1 MiB UTF-8 input/output, and 1024 bytes per numeric token. Malformed text, unsupported values, cycles and profile limits raise catchable errors; syntax errors are ValueError without JSONDecodeError attributes. Allocation/work exhaustion is fatal under the Runtime policy. Float parsing requires a C-compatible numeric locale and nearest rounding. Inputs are never mutated or retained. Failed operations release their partial allocations. Returned values belong to their originating Runtime context and require live roots at collection boundaries. Generated C needs no Python runtime or external JSON library.
Serialize supported Runtime values to a new JSON string with Unicode escaping and explicit separators. Cycles and unsupported types are refused.
obj: positional-or-keyword; required
ensure_ascii: keyword-only; default True
separators: keyword-only; default None
Serialize supported Runtime values to a new JSON string with Unicode escaping and explicit separators. Cycles and unsupported types are refused.
Dictionary keys must be strings. Tuple values become JSON arrays. Cycles raise ValueError; unsupported objects raise TypeError. Inputs remain unchanged.
Argument 1: Supported Runtime value to serialize.
Argument 2: Boolean Unicode escaping switch; True by default.
Argument 3: None for default spacing, or a list/tuple of item and key separator strings.
Returns: A new Unicode string containing the serialized value.
Parse one complete JSON string into new Runtime values. Whitespace is permitted around the document; trailing content is refused.
s: positional-or-keyword; required
Parse one complete JSON string into new Runtime values. Whitespace is permitted around the document; trailing content is refused.
Whitespace is accepted around the document. Duplicate object names keep the last value and first position. Invalid syntax raises ValueError; integers outside int64 raise OverflowError.
Argument 1: One Unicode-scalar string containing a complete JSON document.
Returns: A new Runtime value, list or dictionary; JSON null is None.
*import json
def main():
value=json.loads('{"name":"PCF","values":[1,2.5,true,null],"empty":{}}')
print(json.dumps(value))
print(json.dumps(value,separators=(",",":")))
print(json.loads(json.dumps(value))==value)
print(json.dumps((None,True,False,-9223372036854775808,9223372036854775807,-0.0,5e-324)))
return 0
Expected standard output:
{"name": "PCF", "values": [1, 2.5, true, null], "empty": {}}
{"name":"PCF","values":[1,2.5,true,null],"empty":{}}
True
[null, true, false, -9223372036854775808, 9223372036854775807, -0.0, 5e-324]
Expected exit code: 0
*import json
def main():
value=json.loads('"\\u03a9\\ud83e\\udd85\\u0000\\n"')
print(json.dumps(value))
print(json.dumps(value,ensure_ascii=False))
print(json.loads('"a\\/b\\t\\b\\f\\r\\\\\\\""')=="a/b\t\b\f\r\\\"")
return 0
Expected standard output:
"\u03a9\ud83e\udd85\u0000\n" "Ω🦅\u0000\n" True
Expected exit code: 0