Hisoka-X commented on code in PR #2771:
URL: 
https://github.com/apache/incubator-seatunnel/pull/2771#discussion_r973646515


##########
seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/schema/SeaTunnelSchema.java:
##########
@@ -189,17 +207,25 @@ private static Map<String, String> 
convertConfig2Map(Config config) {
         // So use jackson parsing schema information into a map to keep 
key-value order
         ConfigRenderOptions options = ConfigRenderOptions.concise();
         String schema = config.root().render(options);
-        return JsonUtils.toMap(schema);
+        return convertJson2Map(schema);
     }
 
-    public static SeaTunnelSchema buildWithConfig(Config schemaConfig) {
-        CheckResult checkResult = CheckConfigUtil.checkAllExists(schemaConfig, 
FIELD_KEY);
-        if (!checkResult.isSuccess()) {
-            String errorMsg = String.format("Schema config need option [%s], 
please correct your config first", FIELD_KEY);
-            throw new RuntimeException(errorMsg);
-        }
-        Config fields = schemaConfig.getConfig(FIELD_KEY);
-        Map<String, String> fieldsMap = convertConfig2Map(fields);
+    private static Map<String, String> convertJson2Map(String json) {

Review Comment:
   ```suggestion
       private static Map<String, String> convertJsonToMap(String json) {
   ```



##########
seatunnel-connectors-v2/connector-common/src/main/java/org/apache/seatunnel/connectors/seatunnel/common/schema/SeaTunnelSchema.java:
##########
@@ -189,17 +207,25 @@ private static Map<String, String> 
convertConfig2Map(Config config) {
         // So use jackson parsing schema information into a map to keep 
key-value order
         ConfigRenderOptions options = ConfigRenderOptions.concise();
         String schema = config.root().render(options);
-        return JsonUtils.toMap(schema);
+        return convertJson2Map(schema);
     }
 
-    public static SeaTunnelSchema buildWithConfig(Config schemaConfig) {
-        CheckResult checkResult = CheckConfigUtil.checkAllExists(schemaConfig, 
FIELD_KEY);
-        if (!checkResult.isSuccess()) {
-            String errorMsg = String.format("Schema config need option [%s], 
please correct your config first", FIELD_KEY);
-            throw new RuntimeException(errorMsg);
-        }
-        Config fields = schemaConfig.getConfig(FIELD_KEY);
-        Map<String, String> fieldsMap = convertConfig2Map(fields);
+    private static Map<String, String> convertJson2Map(String json) {
+        ObjectNode jsonNodes = JsonUtils.parseObject(json);
+        LinkedHashMap<String, String> fieldsMap = new LinkedHashMap<>();
+        jsonNodes.fields().forEachRemaining(field -> {
+            String key = field.getKey();
+            JsonNode value = field.getValue();
+            if (value.getNodeType() == JsonNodeType.OBJECT) {
+                fieldsMap.put(key, value.toString());
+            } else {
+                fieldsMap.put(key, value.textValue());
+            }
+        });
+        return fieldsMap;
+    }
+
+    private static SeaTunnelRowType map2SeaTunnelRowType(Map<String, String> 
fieldsMap) {

Review Comment:
   ```suggestion
       private static SeaTunnelRowType mapToSeaTunnelRowType(Map<String, 
String> fieldsMap) {
   ```



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

Reply via email to