View class for rendering JSON responses.
This class inherits from:
Example usage:
class ExampleJSONView(JSONView):
pass
Requesting '/users/john/' with the URL route '/users/<user>/' will then result in the following JSON data:
{
"params": {
"user": "john"
}
}
Probably you want to override the get_context_data() method, to provide your own set of data that will be JSON encoded.
Render the JSON response on GET request.
The keyword-arguments passed by the URL dispatcher are added to the context data.
Returns: | Output of JSONResponseMixin.render_to_response(). |
---|
Get context data for rendering the JSON response.
Returns: | A dict containing the following keys:
|
---|
Mixin class for rendering JSON responses.
Set this to your custom implementation of json.JSONEncoder if needed. Optional.
Render JSON response for the given context data.
Parameters: | context_data – A dict containing the context data. Optional. |
---|---|
Returns: | Output of flask.current_app.response_class() containing the JSON dump with 'application/json' mimetype. |