util/java/src/main/java/com/aliyun/eventbridge/base/EventBridgeUtil.java
public static Object serialize(Object events) {
        if (null == events || !List.class.isAssignableFrom(events.getClass())) {
            return events;
        }
        try {
            List list = (List)events;
            Map<String, Object> map;
            byte[] bytes;
            String data;
            Object result;
            Object contentType;
            List<Map<String, Object>> resultList = new ArrayList<>();
            for (Object object : list) {
                if (TeaModel.class.isAssignableFrom(object.getClass())) {
                    map = ((TeaModel)object).toMap();
                } else {
                    map = (Map<String, Object>)(object);
                }
                contentType = map.get("datacontenttype");
                if (isJsonContentType(contentType)) {
                    result = map.remove("data");
                    if (null != result) {
                        bytes = (byte[])result;
                        String str = new String(bytes, getCharset(contentType));
                        map.put("data", new JsonParser().parse(str));
                    }
                } else {
                    result = map.remove("data");
                    if (null != result) {
                        bytes = (byte[])result;
                        data = BaseEncoding.base64()
                            .encode(bytes);
                        map.put("data_base64", data);
                    }
                }
                result = map.remove("extensions");
                if (null == result) {
                    resultList.add(map);
                    continue;
                }

                Map<String, Object> extensions = (Map<String, Object>)result;
                for (Map.Entry<String, Object> entry : extensions.entrySet()) {
                    map.put(entry.getKey(), entry.getValue());
                }
                resultList.add(map);
            }
            return resultList;
        } catch (Exception e) {
            e.printStackTrace();
            return events;
        }
    }
/**
     * Serialize events
     *
     * @param events the object
     *
     * @return the result
     */
Serialize events
@param events the object

@return the result
Serialize events @param events the object @return the result
public static Object serialize(Object events) {
        if (null == events || !List.class.isAssignableFrom(events.getClass())) {
            return events;
        }
        try {
            List list = (List)events;
            Map<String, Object> map;
            byte[] bytes;
            String data;
            Object result;
            Object contentType;
            List<Map<String, Object>> resultList = new ArrayList<>();
            for (Object object : list) {
                if (TeaModel.class.isAssignableFrom(object.getClass())) {
                    map = ((TeaModel)object).toMap();
                } else {
                    map = (Map<String, Object>)(object);
                }
                contentType = map.get("datacontenttype");
                if (isJsonContentType(contentType)) {
                    result = map.remove("data");
                    if (null != result) {
                        bytes = (byte[])result;
                        String str = new String(bytes, getCharset(contentType));
                        map.put("data", new JsonParser().parse(str));
                    }
                } else {
                    result = map.remove("data");
                    if (null != result) {
                        bytes = (byte[])result;
                        data = BaseEncoding.base64()
                            .encode(bytes);
                        map.put("data_base64", data);
                    }
                }
                result = map.remove("extensions");
                if (null == result) {
                    resultList.add(map);
                    continue;
                }
                Map<String, Object> extensions = (Map<String, Object>)result;
                for (Map.Entry<String, Object> entry : extensions.entrySet()) {
                    map.put(entry.getKey(), entry.getValue());
                }
                resultList.add(map);
            }
            return resultList;
        } catch (Exception e) {
            e.printStackTrace();
            return events;
        }
    }
public static Object serialize ( Object events ) { if ( null == events || ! List . class . isAssignableFrom ( events . getClass ( ) ) ) { return events ; } try { List list = ( List ) events ; Map < String , Object > map ; byte [ ] bytes ; String data ; Object result ; Object contentType ; List < Map < String , Object > > resultList = new ArrayList < > ( ) ; for ( Object object : list ) { if ( TeaModel . class . isAssignableFrom ( object . getClass ( ) ) ) { map = ( ( TeaModel ) object ) . toMap ( ) ; } else { map = ( Map < String , Object > ) ( object ) ; } contentType = map . get ( "datacontenttype" ) ; if ( isJsonContentType ( contentType ) ) { result = map . remove ( "data" ) ; if ( null != result ) { bytes = ( byte [ ] ) result ; String str = new String ( bytes , getCharset ( contentType ) ) ; map . put ( "data" , new JsonParser ( ) . parse ( str ) ) ; } } else { result = map . remove ( "data" ) ; if ( null != result ) { bytes = ( byte [ ] ) result ; data = BaseEncoding . base64 ( ) . encode ( bytes ) ; map . put ( "data_base64" , data ) ; } } result = map . remove ( "extensions" ) ; if ( null == result ) { resultList . add ( map ) ; continue ; } Map < String , Object > extensions = ( Map < String , Object > ) result ; for ( Map . Entry < String , Object > entry : extensions . entrySet ( ) ) { map . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } resultList . add ( map ) ; } return resultList ; } catch ( Exception e ) { e . printStackTrace ( ) ; return events ; } }
Serialize events
 @param events the object
Serialize events @param events the object