jonyangx commented on code in PR #3123:
URL: 
https://github.com/apache/incubator-eventmesh/pull/3123#discussion_r1103734744


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/JsonUtils.java:
##########
@@ -62,72 +63,72 @@ public static String serialize(Object obj) {
         }
     }
 
-    public static <T> byte[] serialize(String topic, Class<T> data) throws 
JsonProcessingException {
-        if (Objects.isNull(data)) {
+    public static byte[] toBytes(Object obj) {
+        if (Objects.isNull(obj)) {
             return null;
         }
         try {
-            return OBJECT_MAPPER.writeValueAsBytes(data);
+            return OBJECT_MAPPER.writeValueAsBytes(obj);
         } catch (JsonProcessingException e) {
             throw new JsonException("serialize to json error", e);
         }
     }
 
     /**
-     * Deserialize json string to object.
+     * parse json string to object.
      *
-     * @param json json string
-     * @param clz  object class
-     * @param <T>  object type
+     * @param text  json string
+     * @param clazz object class
+     * @param <T>   object type
      * @return object
      */
-    public static <T> T deserialize(String json, Class<T> clz) {
-        if (StringUtils.isEmpty(json)) {
+    public static <T> T parseObject(String text, Class<T> clazz) {
+        if (StringUtils.isEmpty(text)) {
             return null;
         }
         try {
-            return OBJECT_MAPPER.readValue(json, clz);
+            return OBJECT_MAPPER.readValue(text, clazz);
         } catch (JsonProcessingException e) {
             throw new JsonException("deserialize json string to object error", 
e);
         }
     }
 
-    public static <T> T deserialize(Class<T> clazz, byte[] bytes) {
+    public static <T> T parseObject(byte[] bytes, Class<T> clazz) {
         if (bytes == null || bytes.length == 0) {
             return null;
         }
         try {
             return OBJECT_MAPPER.readValue(bytes, clazz);
         } catch (IOException e) {
-            throw new JsonException(String.format("deserialize bytes to %s 
error", clazz), e);
+            throw new JsonException(String.format("parse bytes to %s error", 
clazz), e);
         }
     }
 
     /**
-     * Deserialize json string to object.
+     * parse json string to object.
      *
-     * @param str           json string
+     * @param text          json string
      * @param typeReference object type reference
      * @param <T>           object type
      * @return object
      */
-    public static <T> T deserialize(String str, TypeReference<T> 
typeReference) {
-        if (StringUtils.isEmpty(str)) {
+    public static <T> T parseObject(String text, TypeReference<T> 
typeReference) {

Review Comment:
   Method name is inaccurate.Jackson api is readValue().



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to