public static String writeObj(final Object object) {
        String result = null;
        if (object instanceof Long) {
            Long longObj = (Long) object;
            result = writeInt(longObj);
        } else if (object instanceof Integer) {
            Integer intObj = (Integer) object;
            result = writeInt(intObj.longValue());
        } else if (object instanceof Short) {
            Short shObj = (Short) object;
            result = writeInt(shObj.longValue());
        } else if (object instanceof Byte) {
            Byte bObj = (Byte) object;
            result = writeInt(bObj.longValue());
        } else if (object instanceof String) {
            String strObj = (String) object;
            result = writeByteArray(strObj.getBytes(BConst.ASCII));
        } else if (object instanceof byte[]) {
            byte[] bytes = (byte[]) object;
            result = writeByteArray(bytes);
        } else if (object instanceof Iterable) {
            Iterable itObj = (Iterable) object;
            result = writeList(itObj);
        } else if (object instanceof Map) {
            Map mObj = (Map) object;
            result = writeDict(mObj);
        } else {
            throw new IllegalArgumentException(String
                    .format("Unsupport class for serialization: %s.", object.getClass().getName()));
        }
        return result;
    }