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".
datetime
instances will be converted to ISO8601 strings.Decimal
instances 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
Close
Hashes for bottle_rest_serializer-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45f2a2eb89be0f6a517d9427b1b5647fcd67779369fdcbc747812df6beaefe01 |
|
MD5 | 64bbabc510a745ed440fadbe43155d76 |
|
BLAKE2b-256 | cd115d78f51e1d0e3ff44a75ba7f46572efbc6052617bf3348120ae28990da21 |
Close
Hashes for bottle_rest_serializer-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5559361f94a2f28aa8d5e1262475380132f78b29d8ff1b27dc2d5834ff3d250e |
|
MD5 | a6ee535ede4ea1f88c308d4c26de6a29 |
|
BLAKE2b-256 | 70645908587e0d6d7442e28fd65f972eb9f680e87877007507ac03f8965acbfa |