@@ -99,6 +99,10 @@ public AbstractObjectParser(@NotNull JSONObject request, String parentPath, Stri
9999 this .table = Pair .parseEntry (name , true ).getKey ();
100100 this .isTable = zuo .biao .apijson .JSONObject .isTableKey (table );
101101
102+ this .objectCount = 0 ;
103+ this .arrayCount = 0 ;
104+ this .sqlCount = 0 ;
105+
102106 boolean isEmpty = request .isEmpty ();//empty有效 User:{}
103107 if (isEmpty ) {
104108 this .tri = false ;
@@ -216,6 +220,9 @@ public boolean isBreakParse() {
216220 */
217221 protected Map <String , JSONObject > childMap ;
218222
223+ private int objectCount ;
224+ private int arrayCount ;
225+ private int sqlCount ;
219226 /**解析成员
220227 * response重新赋值
221228 * @return null or this
@@ -266,6 +273,7 @@ public AbstractObjectParser parse() throws Exception {
266273 String key ;
267274 Object value ;
268275 int index = 0 ;
276+
269277 for (Entry <String , Object > entry : set ) {
270278 if (isBreakParse ()) {
271279 break ;
@@ -278,7 +286,7 @@ public AbstractObjectParser parse() throws Exception {
278286 key = entry .getKey ();
279287
280288 try {
281- if (value instanceof JSONObject && key .startsWith ("@" ) == false && key .endsWith ("@" ) == false ) {//JSONObject,往下一级提取
289+ if (value instanceof JSONObject && key .startsWith ("@" ) == false && key .endsWith ("@" ) == false ) {//JSONObject,往下一级提取
282290 if (childMap != null ) {//添加到childMap,最后再解析
283291 childMap .put (key , (JSONObject )value );
284292 }
@@ -478,6 +486,13 @@ public JSON onChildParse(int index, String key, JSONObject value) throws Excepti
478486 boolean isEmpty ;
479487
480488 if (zuo .biao .apijson .JSONObject .isArrayKey (key )) {//APIJSON Array
489+ arrayCount ++;
490+
491+ int maxArrayCount = parser .getMaxArrayCount ();
492+ if (arrayCount > maxArrayCount ) {
493+ throw new IllegalArgumentException (path + " 内 key[]: {} 的数量必须在 0-" + maxArrayCount + " 内 !" );
494+ }
495+
481496 if (isMain ) {
482497 throw new IllegalArgumentException (parentPath + "/" + key + ":{} 不合法!"
483498 + "数组 []:{} 中第一个 key:{} 必须是主表 TableKey:{} !不能为 arrayKey[]:{} !" );
@@ -487,6 +502,13 @@ public JSON onChildParse(int index, String key, JSONObject value) throws Excepti
487502 isEmpty = child == null || ((JSONArray ) child ).isEmpty ();
488503 }
489504 else {//APIJSON Object
505+ objectCount ++;
506+
507+ int maxObjectCount = parser .getMaxObjectCount ();
508+ if (objectCount > maxObjectCount ) {
509+ throw new IllegalArgumentException (path + " 内 key: {} 的数量必须在 0-" + maxObjectCount + " 内 !" );
510+ }
511+
490512 if (type == TYPE_ITEM && JSONRequest .isTableKey (Pair .parseEntry (key , true ).getKey ()) == false ) {
491513 throw new IllegalArgumentException (parentPath + "/" + key + ":{} 不合法!"
492514 + "数组 []:{} 中每个 key:{} 都必须是表 TableKey:{} 或 数组 arrayKey[]:{} !" );
@@ -589,6 +611,12 @@ public AbstractObjectParser setSQLConfig(int count, int page, int position) thro
589611 }
590612
591613 if (sqlConfig == null ) {
614+ sqlCount ++;
615+ int maxSQLCount = parser .getMaxSQLCount ();
616+ if (sqlCount > maxSQLCount ) {
617+ throw new IllegalArgumentException (path + " 内生成的 SQL 必须在 0-" + maxSQLCount + " 内 !" );
618+ }
619+
592620 sqlConfig = newSQLConfig ();
593621 }
594622 sqlConfig .setCount (count ).setPage (page ).setPosition (position );
@@ -598,6 +626,8 @@ public AbstractObjectParser setSQLConfig(int count, int page, int position) thro
598626 return this ;
599627 }
600628
629+
630+
601631
602632 protected SQLConfig sqlConfig = null ;//array item复用
603633 /**SQL查询,for array item
0 commit comments