<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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)