public static AbstractResponse deserializeResponse(String json)
	    throws APIException, PermissionException,
	    RequestNotPracticableException, InternalErrorException {
	Object data = deserialize(json, packagePrefixResponse,
		packagePrefixException);
	// NOTE the possible types for data are ... //TODO specify
	if (data instanceof APIException) {
	    throw (APIException) data;
	} else if (data instanceof PermissionException) {
	    throw (PermissionException) data;
	} else if (data instanceof RequestNotPracticableException) {
	    throw (RequestNotPracticableException) data;
	} else if (data instanceof InternalErrorException) {
	    throw (InternalErrorException) data;
	} else {
	    try {
		// Tried all exceptions, now type should be AbstractResponse.
		// If not, the server sent wrong data.
		return (AbstractResponse) data;
	    } catch (ClassCastException ex) {
		throw new APIException(
			"The received object is of unexpected type (expected AbstractResponse or exception).");
	    }
	}
    }