jsonyx.load¶
- jsonyx.load(fp, *, allow=NOTHING, cache_keys=False, hooks=None, root='.')[source]¶
Deserialize an open 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:
allow (
Container[str], default:NOTHING) – the JSON deviations fromjsonyx.allowcache_keys (
bool, default:False) – re-use the keys of objectshooks (
dict[str, _Hook] |None, default:None) – the hooks used for transforming dataroot (_StrPath, default:
".") – the path to the archive containing this JSON file
- Raises:
TruncatedSyntaxError – when failing to decode the file
- Returns:
Any– a Python object
- Example:
>>> import jsonyx as json >>> from io import StringIO >>> io = StringIO('["streaming API"]') >>> json.load(io) ['streaming API']
Tip
Specify
rootto display the zip filename in error messages.