de-serialize a JSON-RPC Response/error

        :Returns: | [result, id] for Responses
        :Raises:  | RPCFault+derivates for error-packages/faults, RPCParseError, RPCInvalidRPC
                  | Note that for error-packages which do not match the
                    V2.0-definition, RPCFault(-1, "Error", RECEIVED_ERROR_OBJ)
                    is raised.

def parse_response(cls, jsonrpc_message):
        """de-serialize a JSON-RPC Response/error

        :Returns: | [result, id] for Responses
        :Raises:  | RPCFault+derivates for error-packages/faults, RPCParseError, RPCInvalidRPC
                  | Note that for error-packages which do not match the
                    V2.0-definition, RPCFault(-1, "Error", RECEIVED_ERROR_OBJ)
                    is raised.
        """
        try:
            data = cls.json_loads(jsonrpc_message)
        except ValueError, err:
            raise errors.RPCParseError("No valid JSON. (%s)" % str(err))
        if not isinstance(data, dict):
            raise errors.RPCInvalidRPC("No valid RPC-package.")
        if "id" not in data:
            raise errors.RPCInvalidRPC("""Invalid Response, "id" missing.""")
        if "result" not in data:
            data["result"] = None #be liberal
        if "error" not in data:
            data["error"] = None #be liberal
        if len(data) != 3:
            raise errors.RPCInvalidRPC("""Invalid Response, additional or missing fields.""")

        #error
        if data["error"] is not None:
            if data["result"] is not None:
                raise errors.RPCInvalidRPC("""Invalid Response, one of "result" or "error" must be null.""")
            #v2.0 error-format
            if (
                isinstance(data["error"], dict) and
                "code" in data["error"] and
                "message" in data["error"] and
                (
                    len(data["error"]) == 2 or
                    ("data" in data["error"] and len(data["error"])==3)
                )
            ):
                if "data" not in data["error"]:
                    error_data = None
                else:
                    error_data = data["error"]["data"]

                if data["error"]["code"] == errors.PARSE_ERROR:
                    raise errors.RPCParseError(error_data)
                elif data["error"]["code"] == errors.INVALID_REQUEST:
                    raise errors.RPCInvalidRPC(error_data)
                elif data["error"]["code"] == errors.METHOD_NOT_FOUND:
                    raise errors.RPCMethodNotFound(error_data)
                elif data["error"]["code"] == errors.INVALID_METHOD_PARAMS:
                    raise errors.RPCInvalidMethodParams(error_data)
                elif data["error"]["code"] == errors.INTERNAL_ERROR:
                    raise errors.RPCInternalError(error_data)
                elif data["error"]["code"] == errors.PROCEDURE_EXCEPTION:
                    raise errors.RPCProcedureException(error_data)
                elif data["error"]["code"] == errors.AUTHENTIFICATION_ERROR:
                    raise errors.RPCAuthentificationError(error_data)
                elif data["error"]["code"] == errors.PERMISSION_DENIED:
                    raise errors.RPCPermissionDenied(error_data)
                elif data["error"]["code"] == errors.INVALID_PARAM_VALUES:
                    raise errors.RPCInvalidParamValues(error_data)
                else:
                    raise errors.RPCFault(data["error"]["code"], data["error"]["message"], error_data)
            #other error-format
            else:
                raise errors.RPCFault(-1, "Error", data["error"])
        #result
        else:
            return data["result"], data["id"]