https://github.com/vzool/camelx
Python serialization for adults
https://github.com/vzool/camelx
Last synced: about 1 year ago
JSON representation
Python serialization for adults
- Host: GitHub
- URL: https://github.com/vzool/camelx
- Owner: vzool
- License: other
- Created: 2024-07-26T03:06:09.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T03:05:57.000Z (almost 2 years ago)
- Last Synced: 2025-05-17T20:12:12.599Z (about 1 year ago)
- Language: Python
- Homepage: https://pypi.org/project/camelx/
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**This fork from "[eevee/camel](https://github.com/eevee/camel)" aims to maintain and potentially enhance the library, the original project has been inactive for years.**
CamelX
=====
CamelX is a library that lets you describe how to serialize your objects to
YAML — and refuses to serialize them if you don't.
If you are interested in contributing, please submit pull requests.
Quick example:
```python
from camelx import Camel, CamelRegistry
class DieRoll(tuple):
def __new__(cls, a, b):
return tuple.__new__(cls, [a, b])
def __repr__(self):
return "DieRoll(%s,%s)" % self
reg = CamelRegistry()
@reg.dumper(DieRoll, u'roll', version=None)
def _dump_dice(data):
return u"{}d{}".format(*data)
@reg.loader(u'roll', version=None)
def _load_dice(data, version):
a, _, b = data.partition(u'd')
return DieRoll(int(a), int(b))
value = DieRoll(3, 6)
camel = Camel([reg])
print(camel.dump(value))
# !roll 3d6
# ...
```
Docs: http://camel.readthedocs.org/en/latest/
GitHub: https://github.com/eevee/camel