Databind is a library inspired by Jackson-databind to describe and bind data models for object-oriented programming.
Project description
databind.core
Databind is a library inspired by Jackson-databind to describe and bind data models for
object-oriented programming. The databind.core
package provides the abstractions to
generalize the (de-) serialization process such that it can be implemented for arbitrary
data formats.
Databind requires Python 3.6+ because of it's dependency on class-member type hints and
the dataclasses
module (for which there exists a backport from Python 3.7 to 3.6 on
PyPI).
Quickstart
from databind.core import datamodel, field
from typing import Optional
@datamodel
class Person:
""" Class that represents a person's details. """
name: str
age: Optional[int] = field(default=None)
address: Optional[str] = field(default=None)
Then you'll need to pick a serialization library. Below is an example for databind.yaml
:
from databind import yaml
person = yaml.from_str(Person, '''
name: John Wick
age: 55
''')
assert isinstance(person, Person)
assert person.name == 'John Wick'
print(yaml.to_str(person))
Copyright © 2020 – Niklas Rosenstein
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for databind.core-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c84c72a82c69fae574a075ffa35909777f08061636c12383fbaa838f1a93e46c |
|
MD5 | 54a60ba9ab0d7732bbc22ccd1d4c6bf5 |
|
BLAKE2b-256 | b062a388ffc65be65592ad3bdefcbe29842b47629a1fe2728dd712beeb92bc36 |