#NEWLINE# def get_json_body( self ) : #NEWLINE# #INDENT# 'Return the body of the request as JSON data.' #NEWLINE# if ( not self . request . body ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# body = self . request . body . strip ( ) . decode ( 'utf-8' ) #NEWLINE# try : #NEWLINE# #INDENT# model = json . loads ( body ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . log . debug ( 'Bad JSON: %r' , body ) #NEWLINE# self . log . error ( "Couldn't parse JSON" , exc_info = True ) #NEWLINE# raise web . HTTPError ( 400 , 'Invalid JSON in body of request' ) #NEWLINE# #UNINDENT# return model