Skip to content

Commit f39d269

Browse files
authored
感谢 DenineLu 贡献:修复请求json的key为JSONArray时类型转换异常问题 Tencent#808
Tencent#808
2 parents 9d5cebb + 672c722 commit f39d269

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ public AbstractObjectParser parse(String name, boolean isReuse) throws Exception
262262
break;
263263
}
264264

265-
String key = entry == null ? null : entry.getKey();
265+
// key可能为JSONArray,需要进行手动转换(fastjson为低版本时允许自动转换,如1.2.21)
266+
// 例如request json为 "{[]:{"page": 2, "table1":{}}}"
267+
Object field = entry == null ? null : entry.getKey();
268+
String key = field instanceof JSONArray ? ((JSONArray) field).toJSONString() : field.toString();
266269
Object value = key == null ? null : entry.getValue();
267270
if (value == null) {
268271
continue;

0 commit comments

Comments
 (0)