fix(JSON-Shcema): 修复JSON-shcema多数组情况下json转译的缺陷

--bug=1008217 --user=宋天阳
【#7970】1.14.2版本,请求体的“JSON-SCHEMA”开关打开和关闭后,json里的信息都丢失了。json体里没有多数组的没有问题,多数组的都有问题
https://www.tapd.cn/55049933/s/1074016
This commit is contained in:
song-tianyang 2021-11-24 14:33:39 +08:00 committed by song-tianyang
parent ba501f32cb
commit 998f7d49a8
1 changed files with 7 additions and 5 deletions

View File

@ -172,11 +172,13 @@ public class JSONSchemaGenerator {
List<Object> array = new LinkedList<>();
JsonArray jsonArray = new JsonArray();
if (object.has("items") && object.get("items").isJsonArray()) {
jsonArray = object.get("items").getAsJsonArray();
} else {
JsonObject itemsObject = object.get("items").getAsJsonObject();
array.add(itemsObject);
if (object.has("items")) {
if(object.get("items").isJsonArray()){
jsonArray = object.get("items").getAsJsonArray();
}else {
JsonObject itemsObject = object.get("items").getAsJsonObject();
array.add(itemsObject);
}
}
for (int i = 0; i < jsonArray.size(); i++) {