fix(接口测试): 修复文档结构导入,null值未展示问题
--bug=1034687 --user=王旭 【接口测试】github#28541,接口测试-文档结构校验导入,值为null的键未导入并展示 https://www.tapd.cn/55049933/s/1546705
This commit is contained in:
parent
566aa3a3ab
commit
26e5fb1578
|
@ -12,6 +12,7 @@ import org.json.XML;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class JSONToDocumentUtil {
|
public class JSONToDocumentUtil {
|
||||||
|
|
||||||
|
@ -54,6 +55,9 @@ public class JSONToDocumentUtil {
|
||||||
jsonDataFormatting((JSONArray) value, childrenElements);
|
jsonDataFormatting((JSONArray) value, childrenElements);
|
||||||
} else {
|
} else {
|
||||||
String type = PropertyConstant.STRING;
|
String type = PropertyConstant.STRING;
|
||||||
|
if (value == JSONObject.NULL || value == null) {
|
||||||
|
value = "null";
|
||||||
|
}
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
type = DocumentUtils.getType(value);
|
type = DocumentUtils.getType(value);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +83,7 @@ public class JSONToDocumentUtil {
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.equals(type, "JSON")) {
|
if (StringUtils.equals(type, "JSON")) {
|
||||||
roots.add(new DocumentElement().newRoot(PropertyConstant.OBJECT, children));
|
roots.add(new DocumentElement().newRoot(PropertyConstant.OBJECT, children));
|
||||||
JSONObject object = JSONUtil.parseObject(json);
|
JSONObject object = new JSONObject(json);
|
||||||
jsonDataFormatting(object, children);
|
jsonDataFormatting(object, children);
|
||||||
} else {
|
} else {
|
||||||
roots.add(new DocumentElement().newRoot(PropertyConstant.OBJECT, children));
|
roots.add(new DocumentElement().newRoot(PropertyConstant.OBJECT, children));
|
||||||
|
|
Loading…
Reference in New Issue