Quick and dirty ORM that maps JSON:API responses to object attributes.
Project description
JSON:API ORM
Quick and dirty ORM that maps JSON:API responses to object attributes.
Free software: BSD license
Documentation: https://jsonapi-orm.readthedocs.io.
How To
Use Requests or (if you are a masochist) Python’s built-in urllib modules to make the request to your JSON:API service and from there pass the response to JSON:API ORM.
So, first install requests and this lib:
pip install requests
pip install jsonapi-orm
Switch to your Python code and use the magic!
import requests
from jsonapi_orm import response_to_obj
# list of items
r = requests.get('http://jsonapiplayground.reyesoft.com/v2/authors')
obj = response_to_obj(r.json())
print('LIST OF ITEMS:')
for item in obj.data:
print(item.name)
# single item
r = requests.get('http://jsonapiplayground.reyesoft.com/v2/authors/1')
obj = response_to_obj(r.json())
print('SINGLE ITEM')
print(obj.data.name)
History
0.1.3 (2018-03-25)
Fixed a bug when child data is non-existent.
0.1.2 (2018-03-25)
Fixed a bug when included is not present in response.
0.1.0 (2018-03-24)
First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonapi-orm-0.1.3.tar.gz
(15.0 kB
view hashes)
Built Distribution
Close
Hashes for jsonapi_orm-0.1.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47fbc24bdd9ebc4c949456ea457b96a63d412e199c4669725a9f464b49a2fcbd |
|
MD5 | ce0d1c1af47754a44ad77e49a13401c6 |
|
BLAKE2b-256 | 05f101f16b927db1d47190b9f51dcaf077cf5d56f4762a6dbbace67442e4b177 |