Skip to main content

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 to float.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bottle_rest_serializer-0.1.4.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bottle_rest_serializer-0.1.4-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

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

Hashes for bottle_rest_serializer-0.1.4.tar.gz
Algorithm Hash digest
SHA256 45f2a2eb89be0f6a517d9427b1b5647fcd67779369fdcbc747812df6beaefe01
MD5 64bbabc510a745ed440fadbe43155d76
BLAKE2b-256 cd115d78f51e1d0e3ff44a75ba7f46572efbc6052617bf3348120ae28990da21

See more details on using hashes here.

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

Hashes for bottle_rest_serializer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5559361f94a2f28aa8d5e1262475380132f78b29d8ff1b27dc2d5834ff3d250e
MD5 a6ee535ede4ea1f88c308d4c26de6a29
BLAKE2b-256 70645908587e0d6d7442e28fd65f972eb9f680e87877007507ac03f8965acbfa

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page