diff --git a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java index ed92c08d74..f555be54c9 100644 --- a/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java +++ b/backend/src/main/java/io/dataease/service/datasource/DatasourceService.java @@ -274,28 +274,29 @@ public class DatasourceService { List datas = JsonPath.read(response,apiDefinition.getDataPath()); List dataList = new ArrayList<>(); + List fields = new ArrayList<>(); + Boolean getFileds = true; + for (LinkedHashMap data : datas) { JSONObject jsonObject = new JSONObject(); Iterator it = data.entrySet().iterator(); while (it.hasNext()){ Map.Entry entry = (Map.Entry)it.next(); jsonObject.put((String) entry.getKey(), entry.getValue()); + if(getFileds) { + DatasetTableField tableField = new DatasetTableField(); + tableField.setOriginName((String) entry.getKey()); + tableField.setName((String) entry.getKey()); + tableField.setSize(65535); + tableField.setDeExtractType(0); + tableField.setDeType(0); + tableField.setExtField(0); + fields.add(tableField); + } } + getFileds = false; dataList.add(jsonObject); } - List fields = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(dataList)){ - for (Map.Entry stringObjectEntry : dataList.get(0).entrySet()) { - DatasetTableField tableField = new DatasetTableField(); - tableField.setOriginName(stringObjectEntry.getKey()); - tableField.setName(stringObjectEntry.getKey()); - tableField.setSize(65535); - tableField.setDeExtractType(0); - tableField.setDeType(0); - tableField.setExtField(0); - fields.add(tableField); - } - } apiDefinition.setDatas(dataList); apiDefinition.setFields(fields); return apiDefinition;