bottle-json-pretty

Return pretty JSON responses from the Bottle Web Framework.


Keywords
bottle, json, pretty
License
MIT
Install
pip install bottle-json-pretty==0.1.1

Documentation

bottle-json-pretty

A plugin for the Bottle Web Framework that returns pretty formatted JSON. The plugin extends the default JSON formatter's behavior by adding the indent keyword argument to each call. This is supported by at least the standard library json, ujson, and simplejson (1, 2, 3).

Indent level and formatting during production can be controlled via the initializer.

from bottle import Bottle
from bottle_json_pretty import JSONPrettyPlugin

app = Bottle(autojson=False)
app.install(JSONPrettyPlugin(indent=2, pretty_production=True))

@app.get('/')
def bottle_test():
    return {
        'status': 'ok',
        'code': 200,
        'messages': [],
        'result': {
            'test': {
                'working': True
            }
        }
    }

app.run()