@@ -578,31 +578,37 @@ private JSONObject getObject(String parentPath, final QueryConfig parentConfig,
578578 throw new IllegalArgumentException ("\" key@\" : 后面必须为依赖路径String!" );
579579 }
580580 // System.out.println("getObject key.endsWith(@) >> parseRelation = " + parseRelation);
581+ // System.out.println("getObject key.endsWith(@) >> parseRelation = " + parseRelation);
581582 String replaceKey = key .substring (0 , key .length () - 1 );//key{}@ getRealKey
582-
583- String valuePath = new String ((String ) value );//改用实时替换[] -> []/i
584-
585- if (valuePath .startsWith (SEPARATOR )) {
586- valuePath = getAbsPath (parentPath , valuePath );
587- } else {//处理[] -> []/i
588- valuePath = replaceArrayChildPath (parentPath , valuePath );
589- value = new String (valuePath );//避免后续重新转换
590- }
583+ String targetPath = getValuePath (parentPath , new String ((String ) value ));
584+
591585 //先尝试获取,尽量保留缺省依赖路径,这样就不需要担心路径改变
592- Object target = getValueByPath (valuePath );
593- Log .i (TAG , "getObject valuePath = " + valuePath + "; target = " + target );
594-
595- if (valuePath .equals (target )) {//必须valuePath和保证getValueByPath传进去的一致!
596- Log .i (TAG , "getObject target != null && target instanceof String"
597- + " && ((String) target).startsWith(valuePath) >> " );
598- Log .i (TAG , "getObject parseRelation == false"
599- + " >> containRelation = true; putRelation(keyPath, valuePath);" );
600- containRelation = true ;
601- } else {//直接替换原来的key@:path为key:target
602- Log .i (TAG , "getObject >> key = replaceKey; value = target;" );
603- key = replaceKey ;
604- value = target ;
586+ Object target = getValueByPath (targetPath );
587+ Log .i (TAG , "getObject targetPath = " + targetPath + "; target = " + target );
588+
589+ if (target == null ) {//String#equals(null)会出错
590+ Log .d (TAG , "getObject target == null >> continue;" );
591+ continue ;
605592 }
593+ if (targetPath .equals (target )) {//必须valuePath和保证getValueByPath传进去的一致!
594+ Log .d (TAG , "getObject targetPath.equals(target) >>" );
595+
596+ //非查询关键词 @key 不影响查询,直接跳过
597+ if (isTableKey && (key .startsWith ("@" ) == false || QueryConfig .TABLE_KEY_LIST .contains (key ))) {
598+ Log .e (TAG , "getObject isTableKey && (key.startsWith(@) == false"
599+ + " || QueryConfig.TABLE_KEY_LIST.contains(key)) >> return null;" );
600+ return null ;//获取不到就不用再做无效的query了。不考虑 Table:{Table:{}}嵌套
601+ } else {
602+ Log .d (TAG , "getObject isTableKey(table) == false >> continue;" );
603+ continue ;//舍去,对Table无影响
604+ }
605+ }
606+
607+
608+ //直接替换原来的key@:path为key:target
609+ Log .i (TAG , "getObject >> key = replaceKey; value = target;" );
610+ key = replaceKey ;
611+ value = target ;
606612 Log .d (TAG , "getObject key = " + key + "; value = " + value );
607613 }
608614
@@ -828,6 +834,20 @@ public int estimateMaxCount(String path, String table, JSONObject value) throws
828834 return response == null ? 0 : response .getIntValue (JSONResponse .KEY_COUNT );
829835 }
830836
837+
838+ /**获取被依赖引用的key的路径, 实时替换[] -> []/i
839+ * @param parentPath
840+ * @param valuePath
841+ * @return
842+ */
843+ private String getValuePath (String parentPath , String valuePath ) {
844+ if (valuePath .startsWith (SEPARATOR )) {
845+ valuePath = getAbsPath (parentPath , valuePath );
846+ } else {//处理[] -> []/i
847+ valuePath = replaceArrayChildPath (parentPath , valuePath );
848+ }
849+ return valuePath ;
850+ }
831851
832852 /**获取绝对路径
833853 * @param path
0 commit comments