JSerPy is a Python library for serializing and deserializing complex objects to and from JSON. It provides robust support for handling various Python types including dataclasses, enums, numpy arrays, and custom objects.
You can install the package directly from GitHub:
pip install git+https://github.com/ronpik/jserpy.gitHere's a simple example of how to use JSerPy:
from dataclasses import dataclass
from jserpy import serialize_json, deserialize_json
@dataclass
class Person:
name: str
age: int
# Create an instance
person = Person(name="John", age=30)
# Serialize to JSON
json_str = serialize_json(person)
# Deserialize back to object
restored_person = deserialize_json(json_str, Person)
assert person == restored_person- Supports serialization of complex Python objects
- Handles dataclasses, enums, numpy arrays, and custom objects
- Type-safe deserialization
- Customizable serialization behavior
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.