Dictaclass

Latest version: v0.6.0

Safety actively analyzes 682471 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

1714332526.118244

dc_deser = to_dataclass(ExampleDC, json.loads(dc_json))
print(dc_deser.timestamp.isoformat())
Output:
2024-04-28T19:28:46.118244+00:00

0.6.0

- Add support for `dataclass`es with `datetime` fields.
- They are expected to be encoded as a UTC timestamp, int or float in the source dictionaries.
- Add a helper function for serializing `dataclass`es with `datetime` fields

Example:
python3
from datetime import datetime
from dataclasses import dataclass
from dictaclass import dataclass_to_dict, json_dumps_default, to_dataclass
import json

dataclass(frozen=True)
class ExampleDC:
timestamp: datetime

dc = ExampleDC(datetime.now())
dc_json = json.dumps(dataclass_to_dict(dc), default=json_dumps_default)
print(dc_json)
Output:

0.5.0

0.1.0

Added
- Ability to apply a name transformer. Mainly useful for naming convention conversions.

**Full Changelog**: https://github.com/BraynStorm/dictaclass/compare/v0.0.3...v0.1.0

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.