jsonyx.loads¶
- jsonyx.loads(s, *, allow=NOTHING, cache_keys=False, filename='<string>', hooks=None)[source]¶
Deserialize a JSON string to a Python object.
Changed in version 2.0: Replaced
use_decimalwithhooks.Changed in version 2.2: Added
cache_keys(defaultFalseinstead ofTrue).- Parameters:
- Raises:
RecursionError – if the JSON string is too deeply nested
TruncatedSyntaxError – when failing to decode the string
ValueError – if a number is too big
- Returns:
Any– a Python object
- Example:
>>> import jsonyx as json >>> json.loads('{"foo": ["bar", null, 1.0, 2]}') {'foo': ['bar', None, 1.0, 2]} >>> json.loads(r'"\"foo\bar"') '"foo\x08ar'
Tip
Specify
filenameto display the filename in error messages.Use
jsonyx.Decoderdirectly for better performance.
Note
The encoding is detected using
jsonyx.detect_encoding().See also
jsonyx.read()for deserializing from a file.jsonyx.load()for deserializing from an open file.jsonyx.dumps()for serializing to a string.