jsonyx.read¶
- jsonyx.read(filename, *, allow=NOTHING, cache_keys=False, hooks=None)[source]¶
Deserialize a JSON file to a Python object.
Changed in version 2.0: Replaced
use_decimalwithhooks.Changed in version 2.2:
Added
cache_keys.Disabled caching keys by default.
- Parameters:
- Raises:
OSError – if the file can’t be opened
TruncatedSyntaxError – when failing to decode the file
- Returns:
Any– a Python object.
- Example:
>>> import jsonyx as json >>> from pathlib import Path >>> from tempfile import TemporaryDirectory >>> with TemporaryDirectory() as tmpdir: ... filename = Path(tmpdir) / "file.json" ... _ = filename.write_text('["filesystem API"]', "utf-8") ... json.read(filename) ... ['filesystem API']