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.json
:
from databind import json
person = json.from_str(Person, '{"name": "John Wick", "age": 55}')
assert isinstance(person, Person)
assert person.name == 'John Wick'
print(json.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.1.post1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d49a783bffd2a5c981ec99a6f2a4b8dc11d51b1275fd4cdbd1d7eaeb6a53504 |
|
MD5 | 0dada8b37c073e845769502d53b51f02 |
|
BLAKE2b-256 | c9d7ec352884db59293a16e4f0d69ccf20b57f09d708ad7481512a3c8a81d281 |
Hashes for databind.core-0.1.1.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b9a12ad6bf774250a90f04a3be95e9fedfcaf3ec10824742391db4a6b5da6a3 |
|
MD5 | e9fd5a3fe6699201d5bd4c0a54049dbb |
|
BLAKE2b-256 | befa9829b0fcee8972523565513acd9a8fa5d2133289dba5f2efaccdfe67b29d |