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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f685f8ca55ccb1dd174e880954e07263a7b0531dd1f5e8a11fa0b71cbaa3dfb |
|
MD5 | d128abffdc91dee35ffab01b44fbdd7c |
|
BLAKE2b-256 | bf54e1724e934594de89037adfa6dfe38328a282e9e8ce7e9ad4afaee5630747 |
Close
Hashes for bottle_rest_serializer-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2527947fa592e9e764fb0d670321e399b43a0afc81a258f7185342f105505ede |
|
MD5 | f1851fbd254e4761a82480df188ab2a6 |
|
BLAKE2b-256 | 55758315c917209f1dfb152086b4e139379504b5f843c88251c76a5d2e619087 |