Hisoka-X commented on code in PR #9103:
URL: https://github.com/apache/seatunnel/pull/9103#discussion_r2125441334


##########
seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/source/HttpSourceReader.java:
##########
@@ -418,47 +421,24 @@ private void collect(Collector<SeaTunnelRow> output, 
String data) throws IOExcep
         deserializationCollector.collect(contentData.getBytes(), output);
     }
 
-    private List<Map<String, String>> parseToMap(List<List<String>> datas, 
JsonField jsonField) {
-        List<Map<String, String>> decodeDatas = new ArrayList<>(datas.size());
-        String[] keys = jsonField.getFields().keySet().toArray(new String[] 
{});
-
-        for (List<String> data : datas) {
-            Map<String, String> decodeData = new 
HashMap<>(jsonField.getFields().size());
-            final int[] index = {0};
-            data.forEach(
-                    field -> {
-                        decodeData.put(keys[index[0]], field);
-                        index[0]++;
-                    });
-            decodeDatas.add(decodeData);
-        }
-
-        return decodeDatas;
-    }
-
     private List<List<String>> decodeJSON(String data) {
         ReadContext jsonReadContext = 
JsonPath.using(jsonConfiguration).parse(data);
-        List<List<String>> results = new ArrayList<>(jsonPaths.length);
-        for (JsonPath path : jsonPaths) {
-            List<String> result = jsonReadContext.read(path);
-            results.add(result);
-        }
-        for (int i = 1; i < results.size(); i++) {
-            List<?> result0 = results.get(0);
-            List<?> result = results.get(i);
-            if (result0.size() != result.size()) {
-                throw new HttpConnectorException(
-                        HttpConnectorErrorCode.FIELD_DATA_IS_INCONSISTENT,
-                        String.format(
-                                "[%s](%d) and [%s](%d) the number of parsing 
records is inconsistent.",
-                                jsonPaths[0].getPath(),
-                                result0.size(),
-                                jsonPaths[i].getPath(),
-                                result.size()));
-            }
+        boolean jsonFiledMissedReturnNull = 
httpParameter.isJsonFiledMissedReturnNull();
+        if (jsonFiledMissedReturnNull) {
+            // Get the appropriate processor for the JsonPaths, passing the
+            // jsonFiledMissedReturnNull flag
+            JsonPathProcessor processor =
+                    JsonPathProcessorFactory.getProcessor(this.jsonPaths, 
true);
+            return processor.processJsonData(jsonReadContext, this.jsonPaths);
+        } else {
+            // Standard processing for strict fields
+            return JsonPathProcessorFactory.getProcessor(this.jsonPaths)
+                    .processJsonData(jsonReadContext, this.jsonPaths);
         }

Review Comment:
   @ocean-zhc 



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