
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
.. image:: https://img.shields.io/pypi/v/jsonapi_orm.svg :target: https://pypi.python.org/pypi/jsonapi_orm
.. image:: https://img.shields.io/circleci/project/github/mislavcimpersak/jsonapi-orm.svg :target: https://circleci.com/gh/mislavcimpersak/jsonapi-orm :alt: CircleCI
.. image:: https://img.shields.io/coveralls/github/mislavcimpersak/jsonapi-orm.svg :target: https://coveralls.io/github/mislavcimpersak/jsonapi-orm :alt: Coveralls github
.. image:: https://readthedocs.org/projects/jsonapi-orm/badge/?version=latest :target: https://jsonapi-orm.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
Quick and dirty ORM that maps JSON:API responses to object attributes.
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:
.. code-block:: bash
pip install requests
pip install jsonapi-orm
Switch to your Python code and use the magic!
.. code-block:: python
import requests
from jsonapi_orm import response_to_obj
# list of items
r = requests.get('https://raw.githubusercontent.com/mislavcimpersak/jsonapi-orm/master/tests/responses/example_list.json')
obj = response_to_obj(r.json())
print('LIST OF ITEMS:')
for item in obj.data:
print(item.title)
# author is defined as a relationship
print(item.author.twitter)
# single item
r = requests.get('https://raw.githubusercontent.com/mislavcimpersak/jsonapi-orm/master/tests/responses/example_single.json')
obj = response_to_obj(r.json())
print('SINGLE ITEM')
print(obj.data.title)
# author is defined as a relationship
print(obj.data.author.id)
print(obj.data.author.twitter)
Since Python object attribute names have certain rules
__ like not starting with a number or not containing "-" char, all such attributes can be accessed using .get()
method. Ie. obj.data.author.get('first-name')
.
If relationship is not described in more detail in the included
part of the response matching fails silently.
For now, this lib does not lazily follow relationship links or anything like that. You can of course make a new request to the given link and pass that response to JSON:API ORM.
For now, there is no check if response is a valid JSON:API response. But you'll probably get that you are trying to parse an invalid response when things start to break.
And last, this lib requires Python 3.5 or newer.
.. _Requests: http://docs.python-requests.org .. _rules: https://docs.python.org/3/reference/lexical_analysis.html#identifiers
__ rules_
FAQs
Quick and dirty ORM that maps JSON:API responses to object attributes.
We found that jsonapi-orm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.