def parse_event_payload(event):
 if (('event' in event) and isinstance(event['event'], basestring)):
  event = event.copy()
  try:
   event['event'] = json.loads(event['event'])
  except ValueError:
   pass
 return event

def parse_event_payload ( event ) : if ( ( 'event' in event ) and isinstance ( event [ 'event' ] , basestring ) ) : event = event . copy ( ) try : event [ 'event' ] = json . loads ( event [ 'event' ] ) except ValueError : pass return event
given an event .