#NEWLINE# def json_response( request , data , status = 200 ) : #NEWLINE# #INDENT# encoded_data = json . dumps ( data , separators = ( ',' , ':' ) ) . encode ( 'utf-8' ) #NEWLINE# mime_type = 'application/json' #NEWLINE# jsonp_callback = request . GET . get ( 'callback' ) #NEWLINE# if jsonp_callback : #NEWLINE# #INDENT# encoded_data = '{jsonp_callback}({encoded_data});' . format ( jsonp_callback = jsonp_callback . encode ( 'utf-8' ) , encoded_data = encoded_data ) #NEWLINE# mime_type = 'application/javascript' #NEWLINE# #UNINDENT# response = HttpResponse ( encoded_data , status = status ) #NEWLINE# response [ 'Content-Type' ] = '{mime_type}; charset=utf-8' . format ( mime_type = mime_type ) #NEWLINE# response [ 'Content-Length' ] = str ( len ( response ) ) #NEWLINE# return response