docs: def json_output(f):
      """
      Format response to json and in case of web-request set response content type
      to 'application/json'.
      """
  
      @wraps(f)
      def json_output_decorator(*args, **kwargs):
          @inject(config=Config)
          def get_config(config):
              return config
  
          config = get_config()
  
          rv = f(*args, **kwargs)
          indent = None
          if config.get('DEBUG', False):
              logging.getLogger(__name__).debug("Formatting JSON nicely.")
              indent = 2
          rv = json.dumps(rv, cls=AppModelJSONEncoder, indent=indent)
          _set_json_response_content_type()
          return rv
  
      return json_output_decorator