LegendPei commented on code in PR #7760:
URL: https://github.com/apache/incubator-seata/pull/7760#discussion_r2559483928


##########
json-common/src/main/java/org/apache/seata/common/json/JsonUtil.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.common.json;
+
+import org.apache.seata.common.ConfigurationKeys;
+import org.apache.seata.common.Constants;
+import org.apache.seata.common.DefaultValues;
+import org.apache.seata.common.exception.JsonParseException;
+import org.apache.seata.config.ConfigurationFactory;
+
+import java.util.Objects;
+
+/**
+ * Unified JSON utility class
+ */
+public final class JsonUtil {
+
+    private static final String CONFIG_JSON_PARSER_NAME = 
ConfigurationFactory.getInstance()
+            .getConfig(
+                    
ConfigurationKeys.TCC_BUSINESS_ACTION_CONTEXT_JSON_PARSER_NAME,
+                    
DefaultValues.DEFAULT_TCC_BUSINESS_ACTION_CONTEXT_JSON_PARSER);
+
+    /**
+     * Serialize the given object to JSON string
+     *
+     * @param object the object to serialize
+     * @return the JSON string representation
+     * @throws JsonParseException if serialization fails
+     */
+    public static String toJSONString(Object object) {
+        return 
JsonSerializerFactory.getSerializer(CONFIG_JSON_PARSER_NAME).toJSONString(object);

Review Comment:
   哦我懂您的意思了,应该在静态初始化时就获取并缓存默认解析器实例,谢谢您的指点,我现在就改一下
   
   Oh, I understand what you mean. We should obtain and cache the default 
parser instance during static initialization. Thank you for your guidance. I'll 
make the change now



-- 
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