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