Bind object-oriented data models to JSON data.
Project description
databind.json
Databind is a library inspired by Jackson-databind to describe and bind data models for
object-oriented programming. The databind.json
package provides converters for JSON data
types, data models and union types to serialize and deserialize JSON payloads.
Quickstart
from typing import Optional
from databind.core import datamodel
from databind.json import from_json
@datamodel
class Geolocation:
latitude: float
longitude: float
altitude: Optional[float] = None
@datamodel
class ResolvedLocation:
query: str
location: Geolocation
london = from_json(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
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
databind.json-0.12.0.tar.gz
(9.6 kB
view hashes)
Built Distribution
Close
Hashes for databind.json-0.12.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9785a0461994a6d2b716d780d1bb3a49c431d4f99c8db943dbd13a75a9b3686f |
|
MD5 | 2551cf32b519e92d9625c9747deb4785 |
|
BLAKE2b-256 | 70eebb546835f9025f6d5bbcf0cbb14c604900446263972fc2ed64753297e9cc |