@@ -484,36 +484,38 @@ public JSON onChildParse(int index, String key, JSONObject value) throws Excepti
484484 boolean isEmpty ;
485485
486486 if (zuo .biao .apijson .JSONObject .isArrayKey (key )) {//APIJSON Array
487+ if (isMain ) {
488+ throw new IllegalArgumentException (parentPath + "/" + key + ":{} 不合法!"
489+ + "数组 []:{} 中第一个 key:{} 必须是主表 TableKey:{} !不能为 arrayKey[]:{} !" );
490+ }
491+
487492 if (arrayConfig == null || arrayConfig .getPosition () == 0 ) {
488493 arrayCount ++;
489494 int maxArrayCount = parser .getMaxArrayCount ();
490495 if (arrayCount > maxArrayCount ) {
491- throw new IllegalArgumentException (path + " 内截至 " + key + " 时数组对象 key[]:{} 的数量达到 " + arrayCount + " 已超限,必须在 0-" + maxArrayCount + " 内 !" );
496+ throw new IllegalArgumentException (path + " 内截至 " + key + ":{} 时数组对象 key[]:{} 的数量达到 " + arrayCount + " 已超限,必须在 0-" + maxArrayCount + " 内 !" );
492497 }
493498 }
494499
495- if (isMain ) {
496- throw new IllegalArgumentException (parentPath + "/" + key + ":{} 不合法!"
497- + "数组 []:{} 中第一个 key:{} 必须是主表 TableKey:{} !不能为 arrayKey[]:{} !" );
498- }
499-
500500 child = parser .onArrayParse (value , path , key , isSubquery );
501501 isEmpty = child == null || ((JSONArray ) child ).isEmpty ();
502502 }
503503 else {//APIJSON Object
504- if (arrayConfig == null || arrayConfig .getPosition () == 0 ) {
504+ boolean isTableKey = JSONRequest .isTableKey (Pair .parseEntry (key , true ).getKey ());
505+ if (type == TYPE_ITEM && isTableKey == false ) {
506+ throw new IllegalArgumentException (parentPath + "/" + key + ":{} 不合法!"
507+ + "数组 []:{} 中每个 key:{} 都必须是表 TableKey:{} 或 数组 arrayKey[]:{} !" );
508+ }
509+
510+ if (//避免使用 "test":{"Test":{}} 绕过限制,实现查询爆炸 isTableKey &&
511+ (arrayConfig == null || arrayConfig .getPosition () == 0 )) {
505512 objectCount ++;
506513 int maxObjectCount = parser .getMaxObjectCount ();
507514 if (objectCount > maxObjectCount ) {
508- throw new IllegalArgumentException (path + " 内截至 " + key + " 时表对象 TableKey :{} 的数量达到 " + objectCount + " 已超限,必须在 0-" + maxObjectCount + " 内 !" );
515+ throw new IllegalArgumentException (path + " 内截至 " + key + ":{} 时对象 key :{} 的数量达到 " + objectCount + " 已超限,必须在 0-" + maxObjectCount + " 内 !" );
509516 }
510517 }
511-
512- if (type == TYPE_ITEM && JSONRequest .isTableKey (Pair .parseEntry (key , true ).getKey ()) == false ) {
513- throw new IllegalArgumentException (parentPath + "/" + key + ":{} 不合法!"
514- + "数组 []:{} 中每个 key:{} 都必须是表 TableKey:{} 或 数组 arrayKey[]:{} !" );
515- }
516-
518+
517519 child = parser .onObjectParse (value , path , key , isMain ? arrayConfig .setType (SQLConfig .TYPE_ITEM_CHILD_0 ) : null , isSubquery );
518520
519521 isEmpty = child == null || ((JSONObject ) child ).isEmpty ();
0 commit comments