JSON serializer suited for REST apis developed with BottlePy
Project description
bottle-rest-serializer
Simple serializers for REST APIs built using BottlePy
Default Python serializers don't work when your dicts/objects contains datetime or Decimal instances. This plugin is meant to fix this "issue".
datetimeinstances will be converted to ISO8601 strings.Decimalinstances will be converted tofloat.
Installation
bottle-rest-serializer is available from PyPI as bottle-rest-serializer:
pip install bottle-rest-serializer
JSON Serializer:
from datetime import datetime
from decimal import Decimal
from bottle import Bottle, run
from truckpad.bottle.rest_serializer import FlexibleJSONPlugin
app = Bottle()
app.install(FlexibleJSONPlugin())
@app.get('/')
def index():
return {
'now': datetime.now(),
'float_number': Decimal(123.4567),
'int_number': Decimal(4567)
}
if __name__ == '__main__':
run(app)
XML Serializer:
To be developed in the future :P
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
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 bottle_rest_serializer-0.1.4.tar.gz.
File metadata
- Download URL: bottle_rest_serializer-0.1.4.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45f2a2eb89be0f6a517d9427b1b5647fcd67779369fdcbc747812df6beaefe01
|
|
| MD5 |
64bbabc510a745ed440fadbe43155d76
|
|
| BLAKE2b-256 |
cd115d78f51e1d0e3ff44a75ba7f46572efbc6052617bf3348120ae28990da21
|
File details
Details for the file bottle_rest_serializer-0.1.4-py3-none-any.whl.
File metadata
- Download URL: bottle_rest_serializer-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5559361f94a2f28aa8d5e1262475380132f78b29d8ff1b27dc2d5834ff3d250e
|
|
| MD5 |
a6ee535ede4ea1f88c308d4c26de6a29
|
|
| BLAKE2b-256 |
70645908587e0d6d7442e28fd65f972eb9f680e87877007507ac03f8965acbfa
|