Initialise an API message from a JSON representation.

def from_json(self, data):
        """
        Initialise an API message from a JSON representation.
        """
        try:
            d = json.loads(data)
        except ValueError:
            raise InvalidMessageException()
        self.from_dict(d)