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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77a617d3721a1fbb420992a2dc2f9c5c60be38e34f4536f0649d23222b64dc63 |
|
MD5 | 6b50ae6bd7663a8ca33dfa10b75e14fc |
|
BLAKE2b-256 | db1f5b7060583e7af260d24f8f9292bba66bcf1f7eb61324f4497c5a0fa4de01 |
Close
Hashes for bottle_rest_serializer-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c809908ae9d95db40a8254dbcb4081b7df6290b6c30b7ae23b0f3bd0e392012 |
|
MD5 | 2fc7bc489952781a41fd777cc93a3323 |
|
BLAKE2b-256 | 2c392121719af175d6a1528d07a34dfc4e69db8503049ddfcb872a21e104b9e0 |