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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff309dfeb3c2a1c6183ebc3e2bbf2a82ea0f4e26d918b3faa766e152f53a1ba |
|
MD5 | c2a3155f7cb0ec76b4f00dac1b08ac81 |
|
BLAKE2b-256 | 82831f2df08c3debd920e027eb019711775cd4781997323a485470cb6d96908c |
Close
Hashes for bottle_rest_serializer-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4d3fb55fbee7d1b8ef7a5b07b89012b7be48fc68daf7fc1ca4673636f0c40f0 |
|
MD5 | 275c61f9ecebae71f008c521059e148f |
|
BLAKE2b-256 | d093e87955acf5d3f35ad3426a205fd0e9ffc64da7ad99893df63efd679c5133 |