forked from github/dataease
commit
6ba4e8fe46
@ -266,13 +266,11 @@ public class ApiProvider extends Provider {
|
|||||||
for (String s : jsonObject.keySet()) {
|
for (String s : jsonObject.keySet()) {
|
||||||
String value = jsonObject.getString(s);
|
String value = jsonObject.getString(s);
|
||||||
if (StringUtils.isNotEmpty(value) && value.startsWith("[")) {
|
if (StringUtils.isNotEmpty(value) && value.startsWith("[")) {
|
||||||
|
|
||||||
JSONObject o = new JSONObject();
|
JSONObject o = new JSONObject();
|
||||||
try {
|
try {
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray(s);
|
JSONArray jsonArray = jsonObject.getJSONArray(s);
|
||||||
List<JSONObject> childrenField = new ArrayList<>();
|
List<JSONObject> childrenField = new ArrayList<>();
|
||||||
for (Object object : jsonArray) {
|
for (Object object : jsonArray) {
|
||||||
JSONObject.parseObject(object.toString());
|
|
||||||
handleStr(apiDefinition, JSON.toJSONString(object, SerializerFeature.WriteMapNullValue), childrenField, rootPath + "." + s + "[*]");
|
handleStr(apiDefinition, JSON.toJSONString(object, SerializerFeature.WriteMapNullValue), childrenField, rootPath + "." + s + "[*]");
|
||||||
}
|
}
|
||||||
o.put("children", childrenField);
|
o.put("children", childrenField);
|
||||||
@ -289,15 +287,28 @@ public class ApiProvider extends Provider {
|
|||||||
fields.add(o);
|
fields.add(o);
|
||||||
}
|
}
|
||||||
} else if (StringUtils.isNotEmpty(value) && value.startsWith("{")) {
|
} else if (StringUtils.isNotEmpty(value) && value.startsWith("{")) {
|
||||||
List<JSONObject> children = new ArrayList<>();
|
try {
|
||||||
handleStr(apiDefinition, jsonObject.getString(s), children, rootPath + "." + String.format(path, s));
|
JSONObject.parseObject(jsonStr);
|
||||||
JSONObject o = new JSONObject();
|
List<JSONObject> children = new ArrayList<>();
|
||||||
o.put("children", children);
|
handleStr(apiDefinition, jsonObject.getString(s), children, rootPath + "." + String.format(path, s));
|
||||||
o.put("childrenDataType", "OBJECT");
|
JSONObject o = new JSONObject();
|
||||||
o.put("jsonPath", rootPath + "." + s);
|
o.put("children", children);
|
||||||
setProperty(apiDefinition, o, s);
|
o.put("childrenDataType", "OBJECT");
|
||||||
if (!hasItem(apiDefinition, fields, o)) {
|
o.put("jsonPath", rootPath + "." + s);
|
||||||
fields.add(o);
|
setProperty(apiDefinition, o, s);
|
||||||
|
if (!hasItem(apiDefinition, fields, o)) {
|
||||||
|
fields.add(o);
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
JSONObject o = new JSONObject();
|
||||||
|
o.put("jsonPath", rootPath + "." + String.format(path, s));
|
||||||
|
setProperty(apiDefinition, o, s);
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
array.add(StringUtils.isNotEmpty(jsonObject.getString(s)) ? jsonObject.getString(s) : "");
|
||||||
|
o.put("value", array);
|
||||||
|
if (!hasItem(apiDefinition, fields, o)) {
|
||||||
|
fields.add(o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
JSONObject o = new JSONObject();
|
JSONObject o = new JSONObject();
|
||||||
@ -325,13 +336,13 @@ public class ApiProvider extends Provider {
|
|||||||
o.put("deType", 0);
|
o.put("deType", 0);
|
||||||
o.put("extField", 0);
|
o.put("extField", 0);
|
||||||
o.put("checked", false);
|
o.put("checked", false);
|
||||||
for (DatasetTableFieldDTO fieldDTO : apiDefinition.getFields()) {
|
// for (DatasetTableFieldDTO fieldDTO : apiDefinition.getFields()) {
|
||||||
if (StringUtils.isNotEmpty(o.getString("jsonPath")) && StringUtils.isNotEmpty(fieldDTO.getJsonPath()) && fieldDTO.getJsonPath().equals(o.getString("jsonPath"))) {
|
// if (StringUtils.isNotEmpty(o.getString("jsonPath")) && StringUtils.isNotEmpty(fieldDTO.getJsonPath()) && fieldDTO.getJsonPath().equals(o.getString("jsonPath"))) {
|
||||||
o.put("checked", true);
|
// o.put("checked", true);
|
||||||
o.put("deExtractType", fieldDTO.getDeExtractType());
|
// o.put("deExtractType", fieldDTO.getDeExtractType());
|
||||||
o.put("name", fieldDTO.getName());
|
// o.put("name", fieldDTO.getName());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user