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.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.2.tar.gz
(15.0 kB
view hashes)
Built Distribution
Close
Hashes for jsonapi_orm-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ef19658d7f1cf75c272884d2f1f7829d04550a3249ee0b167ddb490f2e96fa |
|
MD5 | 0c4201d9b6ad7d0d5bd548266e06249f |
|
BLAKE2b-256 | cb8aada72144817a3b62ee4301b4330be32372aa9b3d293d6e13606118b84fb2 |