flask request get_json None
content = request.get_json(silent=True)If the mimetype is application/json this will contain the parsed JSON data. Otherwise this will be None.
get_json(force=False, silent=False, cache=True)Parses the incoming JSON request data and returns it. If parsing fails the on_json_loading_failed() method on the request object will be invoked. By default this function will only load the json data if the mimetype is application/json but this can be overridden by the force parameter.Parameters:force – if set to True the mimetype is ignored.silent – if set to True this method will fail silently and return None.cache – if set to True the parsed JSON data is remembered on the request.
on_json_loading_failed(e)¶Called if decoding of the JSON data failed. The return value of this method is used by get_json() when an error occurred. The default implementation just raises a BadRequest exception.Changed in version 0.10: Removed buggy previous behavior of generating a random JSON response. If you want that behavior back you can trivially add it by subclassing.New in version 0.8.