Skip to main content

De/serialize YAML payloads using Python type hints.

Project description

databind.yaml

Databind is a library inspired by Jackson-databind to describe and bind data models for object-oriented programming. The databind.yaml module provides functionality to (de-) serialize YAML payloads from/to Python objects.

Note: This module is just a thin wrapper that provides utility functions, combining the functionality of databind.json with PyYAML.

Quickstart

from typing import Optional
from databind.core import datamodel
from databind.yaml import from_str

@datamodel
class Geolocation:
  latitude: float
  longitude: float
  altitude: Optional[float] = None

@datamodel
class ResolvedLocation:
  query: str
  location: Geolocation

london = from_str(ResolvedLocation, '''
query: London
location:
  latitude: 51.507351
  longitude: -0.127758
''')

assert london == ResolvedLocation("London", Geolocation(51.507351, -0.127758))

Copyright © 2020 Niklas Rosenstein

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for databind.yaml, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size databind.yaml-0.1.3-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size databind.yaml-0.1.3.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page