Skip to content

Commit

Permalink
解决 PUT 请求传 @key:[] 被当成表字段然后解析报错
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Dec 26, 2020
1 parent d7905ff commit 3e86b09
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,36 +222,42 @@ public AbstractObjectParser parse() throws Exception {
key = entry.getKey();

try {
if (value instanceof JSONObject && key.startsWith("@") == false && key.endsWith("@") == false) { //JSONObject,往下一级提取
if (childMap != null) {//添加到childMap,最后再解析
if (key.startsWith("@") || key.endsWith("@")) {
if (onParse(key, value) == false) {
invalidate();
}
}
else if (value instanceof JSONObject) { // JSONObject,往下一级提取
if (childMap != null) { // 添加到childMap,最后再解析
childMap.put(key, (JSONObject)value);
}
else { //直接解析并替换原来的,[]:{} 内必须直接解析,否则会因为丢掉count等属性,并且total@:"/[]/total"必须在[]:{} 后!
else { // 直接解析并替换原来的,[]:{} 内必须直接解析,否则会因为丢掉count等属性,并且total@:"/[]/total"必须在[]:{} 后!
response.put(key, onChildParse(index, key, (JSONObject)value));
index ++;
}
}
else if ((method == POST || method == PUT) && value instanceof JSONArray && JSONRequest.isTableArray(key)) { //JSONArray,批量新增或修改,往下一级提取
else if ((method == POST || method == PUT) && value instanceof JSONArray
&& JSONRequest.isTableArray(key)) { // JSONArray,批量新增或修改,往下一级提取
onTableArrayParse(key, (JSONArray) value);
}
else if (method == PUT && value instanceof JSONArray
&& (whereList == null || whereList.contains(key) == false)) { //PUT JSONArray
&& (whereList == null || whereList.contains(key) == false)) { // PUT JSONArray
onPUTArrayParse(key, (JSONArray) value);
}
else {//JSONArray或其它Object,直接填充
else { // JSONArray或其它Object,直接填充
if (onParse(key, value) == false) {
invalidate();
}
}
} catch (Exception e) {
if (tri == false) {
throw e;//不忽略错误,抛异常
throw e; // 不忽略错误,抛异常
}
invalidate();//忽略错误,还原request
invalidate(); // 忽略错误,还原request
}
}

//非Table内的函数会被滞后在onChildParse后调用! onFunctionResponse("-");
// 非Table内的函数会被滞后在onChildParse后调用! onFunctionResponse("-");
}

if (isTable) {
Expand Down

0 comments on commit 3e86b09

Please sign in to comment.