fix(接口测试): 修复文档结构导入,null值未展示问题

--bug=1034687 --user=王旭 【接口测试】github#28541,接口测试-文档结构校验导入,值为null的键未导入并展示 https://www.tapd.cn/55049933/s/1546705
This commit is contained in:
WangXu10 2024-07-11 13:47:10 +08:00 committed by Craftsman
parent 566aa3a3ab
commit 26e5fb1578
1 changed files with 5 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import org.json.XML;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
public class JSONToDocumentUtil {
@ -54,6 +55,9 @@ public class JSONToDocumentUtil {
jsonDataFormatting((JSONArray) value, childrenElements);
} else {
String type = PropertyConstant.STRING;
if (value == JSONObject.NULL || value == null) {
value = "null";
}
if (value != null) {
type = DocumentUtils.getType(value);
}
@ -79,7 +83,7 @@ public class JSONToDocumentUtil {
} else {
if (StringUtils.equals(type, "JSON")) {
roots.add(new DocumentElement().newRoot(PropertyConstant.OBJECT, children));
JSONObject object = JSONUtil.parseObject(json);
JSONObject object = new JSONObject(json);
jsonDataFormatting(object, children);
} else {
roots.add(new DocumentElement().newRoot(PropertyConstant.OBJECT, children));