<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sign_json(self, json):
 """Signs a JSON object. NOTE: The object is modified in-place and the return value can be ignored. As specified, this is done by encoding the JSON object without ``signatures`` or keys grouped as ``unsigned``, using canonical encoding. Args: json (dict):
 The JSON object to sign. Returns: The same JSON object, with a ``signatures`` key added. It is formatted as ``"signatures": ed25519:<device_id>: <base64_signature>``. """

        signatures = json.pop('signatures', {})
        unsigned = json.pop('unsigned', None)

        signature_base64 = self.olm_account.sign(encode_canonical_json(json))

        key_id = 'ed25519:{}'.format(self.device_id)
        signatures.setdefault(self.user_id, {})[key_id] = signature_base64

        json['signatures'] = signatures
        if unsigned:
            json['unsigned'] = unsigned

        return json