semvec/pypi-packages huggingface dataset:
json-deserializer 0.0.7
Attempts to correctly deserialize objects that json decoder cannot.
License: Apache 2.0

# json-deserializer

Attempts to deserialize objects into a format that json.dumps/json.loads can use.
- Anything that is a Sequence, but not a str will be cast to a list.
- All Mappings will be cast to dicts
- Decimal to floats
- Callable to string (will return Object.__repr__)
- NamedTuple to dict


## Usage Example

```python
    >>> from json import dumps
    >>> from collections import UserDict
    >>> from json_deserializer import deserialize
    >>>
    >>> class MyDict(UserDict):
    >>>     pass
    >>>
    >>> d = MyDict({"foo": "bar"})
    >>> try:
    >>>    dumps(d)
    >>> except Exception as e:
    >>>    print(e)
    Object of type MyDict is not JSON serializable
    >>> dumps(d, default=deserialize)
    '{"foo": "bar"}'

You can also import dump, load, dumps, and loads directly from json_deserializer which will call json.loads, json.dumps with default=json_deserializer.deserialize.