jospy
jospy is a small Python utility package for JSON payloads and REST API
responses. It uses Python's built-in json module and adds a friendlier layer
for common backend work: JSON to Python, Python to JSON, null handling, default
filling, filtering, nested paths, and response envelopes.
Install it locally while developing:
pip install -e ".[dev]"
Basic usage:
from jospy import api_response, fill, filter_data, null, to_json, to_python
payload = to_python('{"name": "Ada", "email": null}')
payload = fill(payload, {"active": True, "email": "unknown@example.com"})
public_payload = filter_data(payload, exclude=["password"], drop_nulls=True)
body = to_json(api_response(public_payload, message="ok"), pretty=True)
Highlights:
to_python()/from_json()convert JSON strings, bytes, or files to Python.to_json()serializes Python data to compact or pretty JSON.null()returnsNonewith no arguments, or checks if values areNone.fill()recursively fills missing orNonefields with defaults.filter_data()filters dictionaries or lists by fields, predicates, and nulls.pick()/omit()are quick field-selection helpers.get_path()/set_path()work with nested dot paths likeuser.email.api_response()andpaginated()create consistent REST API response shapes.
REST API example:
from jospy import api_response, paginated
def get_user_response(user):
return api_response(user, message="User loaded")
def list_users_response(users, page=1):
return paginated(users, page=page, per_page=25)
Documentation
See docs/index.md for the full helper reference and examples.
Development
Run tests:
python -m pytest
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jospy-0.1.0.tar.gz.
File metadata
- Download URL: jospy-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fc2e3738aadeb536bde84ae527b336f716bea47114cc70bfc28a6b4e0453306
|
|
| MD5 |
d51d13f852e48ba9562cf7364341e066
|
|
| BLAKE2b-256 |
e4796d530a81f366e5b48357737eb2774d957017977ff3d190e3f6de71389b02
|
File details
Details for the file jospy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jospy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
491931a0083bdbc3878497b45005b28900d92a226349833efc7da5ad7e7266f4
|
|
| MD5 |
70884a3173e1725088cf7c715ea64f1c
|
|
| BLAKE2b-256 |
8f7eb69c8b7f2b571bfa8f650665c8c607e85a9e5a396e1d43d7418257563896
|