Skip to content

Commit 6a5e1ed

Browse files
committed
Server:当引用赋值引用requestObject里的对象{}时直接判断为无值;优化log
1 parent fc217f0 commit 6a5e1ed

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractObjectParser.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -307,32 +307,36 @@ public boolean onParse(@NotNull String key, @NotNull Object value) throws Except
307307

308308
//先尝试获取,尽量保留缺省依赖路径,这样就不需要担心路径改变
309309
Object target = onReferenceParse(targetPath);
310-
Log.i(TAG, "getObject targetPath = " + targetPath + "; target = " + target);
310+
Log.i(TAG, "onParse targetPath = " + targetPath + "; target = " + target);
311311

312312
if (target == null) {//String#equals(null)会出错
313-
Log.d(TAG, "getObject target == null >> continue;");
313+
Log.d(TAG, "onParse target == null >> continue;");
314314
return true;
315315
}
316+
if (target instanceof Map) { //target可能是从requestObject里取出的 {}
317+
Log.d(TAG, "onParse target instanceof Map >> continue;");
318+
return false;
319+
}
316320
if (targetPath.equals(target)) {//必须valuePath和保证getValueByPath传进去的一致!
317-
Log.d(TAG, "getObject targetPath.equals(target) >>");
321+
Log.d(TAG, "onParse targetPath.equals(target) >>");
318322

319323
//非查询关键词 @key 不影响查询,直接跳过
320324
if (isTable && (key.startsWith("@") == false || JSONRequest.TABLE_KEY_LIST.contains(key))) {
321-
Log.e(TAG, "getObject isTable && (key.startsWith(@) == false"
325+
Log.e(TAG, "onParse isTable && (key.startsWith(@) == false"
322326
+ " || JSONRequest.TABLE_KEY_LIST.contains(key)) >> return null;");
323327
return false;//获取不到就不用再做无效的query了。不考虑 Table:{Table:{}}嵌套
324328
} else {
325-
Log.d(TAG, "getObject isTable(table) == false >> continue;");
329+
Log.d(TAG, "onParse isTable(table) == false >> continue;");
326330
return true;//舍去,对Table无影响
327331
}
328332
}
329333

330334

331335
//直接替换原来的key@:path为key:target
332-
Log.i(TAG, "getObject >> key = replaceKey; value = target;");
336+
Log.i(TAG, "onParse >> key = replaceKey; value = target;");
333337
key = replaceKey;
334338
value = target;
335-
Log.d(TAG, "getObject key = " + key + "; value = " + value);
339+
Log.d(TAG, "onParse key = " + key + "; value = " + value);
336340
}
337341

338342
if (key.endsWith("()")) {
@@ -376,7 +380,7 @@ public JSON onChildParse(int index, String key, JSONObject value) throws Excepti
376380
invalidate();
377381
}
378382
}
379-
Log.i(TAG, "getObject ObjectParser.onParse key = " + key + "; child = " + child);
383+
Log.i(TAG, "onChildParse ObjectParser.onParse key = " + key + "; child = " + child);
380384

381385
return isEmpty ? null : child;//只添加! isChildEmpty的值,可能数据库返回数据不够count
382386
}
@@ -392,7 +396,7 @@ public JSON onChildParse(int index, String key, JSONObject value) throws Excepti
392396
@Override
393397
public void onPUTArrayParse(@NotNull String key, @NotNull JSONArray array) throws Exception {
394398
if (isTable == false || array.isEmpty()) {
395-
Log.e(TAG, "onPUTArray isTable == false || array == null || array.isEmpty() >> return;");
399+
Log.e(TAG, "onPUTArrayParse isTable == false || array == null || array.isEmpty() >> return;");
396400
return;
397401
}
398402

0 commit comments

Comments
 (0)