Library for dumping models into JSON:API
Project description
JSON:APy - Loading and Dumping JSON:API in Python
WIP: this library is still in early development phase.
jsonapy
is a Python library for dumping models into
JSON:API-compliant JSON.
Installation
With pip
:
pip install jsonapy
Basic usage overview
This package lets you define models and dump them into dict with the JSON:API structure. First, define a resource:
import jsonapy
class PersonResource(jsonapy.BaseResource):
id: int
first_name: str
last_name: str
class Meta:
resource_name = "person"
You can now dump an instance of this resource into JSON:API-structured dictionary:
guido = PersonResource(id=1, first_name="Guido", last_name="Van Rossum")
data = guido.jsonapi_dict(required_attributes="__all__")
The resulting data
dictionary can be represented by:
{
'type': 'person',
'id': 1,
'attributes': {
'firstName': 'Guido',
'lastName': 'Van Rossum'
}
}
Documentation
The complete documentation can be found here. It is built with pdoc.
Roadmap
Refer to the project to view the roadmap-related issues.
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
jsonapy-0.1.3.dev0.tar.gz
(13.7 kB
view hashes)
Built Distribution
Close
Hashes for jsonapy-0.1.3.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 140a53d5d17db60c142dfbaff34277726ba78e205e94603cb31b5b0460746abd |
|
MD5 | 2087927e3e6f19fff55a89430b3a339d |
|
BLAKE2b-256 | fe29bb5b1d6a2b4e5eda347089f9bc1de34d54d4aa1c0c0f56e85b18ce4f9ba3 |