Starlette Marshal
This package has two usage.Provide a "JSONResponse" to replace simple Starlette "JSONResponse" and works with other Python JSON libraries. And offer a "json" library to replace Python "json" library, so we can use it instead.
Installation
To install base package:
pip install -U starlette-marshal
to support RapidJSON:
pip install -U starlette-marshal[rapidjson]
or if you prefer the latest development version, you can install it from the source:
Quickstart
We want to be soft dependency. So this package is 100% compatible with standard Python and Starlette package. To archive this goal you can import it like this:
try:
from starlette_marshal import json
except ImportError:
import json
try:
from starlette_marshal import JSONResponse
except ImportError:
from starlette.responses import JSONResponse
the usage is just like Starlette itself:
async def get(request: Request) -> Response:
content: dict = {
'foo': 'This is foo',
'bar': 'And here the bar',
}
return JSONResponse(content=content)
and for "json" library:
async def post(request: Request) -> Response:
body: dict = json.loads(s=await request.body())
return JSONResponse(content=body)
TODO
- Support RapidJSON
- Support UltraJSON
- Support simplejson
- Support orjson
Release files for starlette-marshal 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| starlette-marshal-0.1.0.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| starlette_marshal-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / starlette-marshal-0.1.0.tar.gz
| Download URL | starlette-marshal-0.1.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f64eeb9829a9537afabfbd81f9fb027bdb0365db647f397d33c648140431d0b
|
|
BLAKE2b-256 checksum How to use checksums |
b82a8256507594d8c2a49382d7e366e548cb4318cfcc20b558075bcd91ead217
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Release files / starlette_marshal-0.1.0-py3-none-any.whl
| Download URL | starlette_marshal-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d20b7ca74a1396084d8513261647d2364cc2f8d8632e0af083b6cbc045d1f2d8
|
|
BLAKE2b-256 checksum How to use checksums |
15506c97b1d8decaae3526ce7708226cbf32e817e7fdfb83b34739be71b0da67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|