Skip to main content
https://github.com/skozlovf/flask-json/actions/workflows/test.yml/badge.svg?branch=master

Flask-JSON is a simple extension that adds better JSON support to Flask application.

Features:

  • Works on python 2.6, 2.7, 3.3+ and Flask 0.10+.

  • More ways to generate JSON responses (comparing to plain Flask).

  • Extended JSON encoding support.

Usage

Here is fast example:

from datetime import datetime
from flask import Flask
from flask_json import FlaskJSON, JsonError, json_response, as_json

app = Flask(__name__)
FlaskJSON(app)


@app.route('/get_time')
def get_time():
    return json_response(time=datetime.utcnow())


@app.route('/get_time_and_value')
@as_json
def get_time_and_value():
    return dict(time=datetime.utcnow(), value=12)


@app.route('/raise_error')
def raise_error():
    raise JsonError(description='Example text.', code=123)


if __name__ == '__main__':
    app.run()

Responses:

GET /get_time HTTP/1.1

HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 60

{
  "status": 200,
  "time": "2015-04-14T13:17:16.732000"
}
GET /raise_error HTTP/1.1

HTTP/1.0 400 BAD REQUEST
Content-Type: application/json
Content-Length: 70

{
  "code": 123,
  "description": "Example text.",
  "status": 400
}

Documentation

Documentation is available on Read the Docs.

Metadata

Release files for Flask-JSON 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-JSON 0.4.0
File Size Uploaded
Flask-JSON-0.4.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-JSON 0.4.0
File Interpreter ABI Platform
Flask_JSON-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.6 kB

Release files / Flask-JSON-0.4.0.tar.gz

Download URL Flask-JSON-0.4.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
07945d66024f3b77694ce1db5d1fe83940f2aa3bcad8a608535686be67e4bc48
BLAKE2b-256 checksum
How to use checksums
ba4a6046e195241772f4b6add3adcd4e820004c6151afc587d8c7d0d4ffeb473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Release files / Flask_JSON-0.4.0-py3-none-any.whl

Download URL Flask_JSON-0.4.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c1b87a657daa2179fc19f1ffc78204a716c7c5139673dc5038772db4d9f1988
BLAKE2b-256 checksum
How to use checksums
ae873b3ae3ca23dd90b15faa1128c473c1cf16d42e9f95efc5e4a1b77bf22260
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page