Write JSON response.
(self, values, status=200)
| 214 | """A hook for modifying values before render_json.""" |
| 215 | |
| 216 | def render_json(self, values, status=200): |
| 217 | """Write JSON response.""" |
| 218 | response = Response() |
| 219 | response = self._add_security_response_headers(response) |
| 220 | response.headers['Content-Type'] = 'application/json' |
| 221 | self.before_render_json(values, status) |
| 222 | response.data = json.dumps(values, cls=JsonEncoder) |
| 223 | response.status_code = status |
| 224 | return response |
| 225 | |
| 226 | def handle_exception(self, exception): |
| 227 | """Catch exception and format it properly.""" |