def from_json(data):
        """Decode event encoded as JSON by processor"""

        parsed_data = json.loads(data)
        trigger = TriggerInfo(
            parsed_data['trigger']['class'],
            parsed_data['trigger']['kind'],
        )

        # extract content type, needed to decode body
        content_type = parsed_data['content_type']

        return Event(body=Event.decode_body(parsed_data['body'], content_type),
                     content_type=content_type,
                     trigger=trigger,
                     fields=parsed_data.get('fields'),
                     headers=parsed_data.get('headers'),
                     _id=parsed_data['id'],
                     method=parsed_data['method'],
                     path=parsed_data['path'],
                     size=parsed_data['size'],
                     timestamp=datetime.datetime.utcfromtimestamp(parsed_data['timestamp']),
                     url=parsed_data['url'],
                     _type=parsed_data['type'],
                     type_version=parsed_data['type_version'],
                     version=parsed_data['version'])
def from_json ( data ) : parsed_data = json . loads ( data ) trigger = TriggerInfo ( parsed_data [ 'trigger' ] [ 'class' ] , parsed_data [ 'trigger' ] [ 'kind' ] , ) content_type = parsed_data [ 'content_type' ] return Event ( body = Event . decode_body ( parsed_data [ 'body' ] , content_type ) , content_type = content_type , trigger = trigger , fields = parsed_data . get ( 'fields' ) , headers = parsed_data . get ( 'headers' ) , _id = parsed_data [ 'id' ] , method = parsed_data [ 'method' ] , path = parsed_data [ 'path' ] , size = parsed_data [ 'size' ] , timestamp = datetime . datetime . utcfromtimestamp ( parsed_data [ 'timestamp' ] ) , url = parsed_data [ 'url' ] , _type = parsed_data [ 'type' ] , type_version = parsed_data [ 'type_version' ] , version = parsed_data [ 'version' ] )
Decode event encoded as JSON by processor