You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2022/06/30 03:34:04 UTC

[GitHub] [incubator-eventmesh] VNBear commented on a diff in pull request #974: [ISSUE #973] zookeeper registry

VNBear commented on code in PR #974:
URL: https://github.com/apache/incubator-eventmesh/pull/974#discussion_r910575323


##########
eventmesh-registry-plugin/eventmesh-registry-zookeeper/src/main/java/org/apache/eventmesh/registry/zookeeper/util/JsonUtils.java:
##########
@@ -0,0 +1,26 @@
+package org.apache.eventmesh.registry.zookeeper.util;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class JsonUtils {
+
+    public static String toJSON(Object o) {
+        ObjectMapper objectMapper = new ObjectMapper();
+        try {
+            return objectMapper.writeValueAsString(o);
+        } catch (JsonProcessingException e) {
+            return null;
+        }
+    }
+
+    public static <T> T parseJson(String json, Class<T> c) {
+        ObjectMapper objectMapper = new ObjectMapper();
+        try {
+
+            return objectMapper.readValue(json, c);
+        } catch (JsonProcessingException e) {
+            return null;
+        }

Review Comment:
   tks, i will be  optimize



-- 
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: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org