Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 107fd37

Browse files
committed
解决 FunctionParser 初始化等触发 JSONRequest.put 中转 JSON 报错,删除不再需要的 @JSONFiled
1 parent 2bb6a7d commit 107fd37

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
lines changed

APIJSONORM/src/main/java/apijson/JSON.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ public static Object parseJSON(Object json) {
100100
return parseArray(json, DEFAULT_JSON_PARSER);
101101
}
102102

103-
throw new IllegalArgumentException("JSON 格式错误!" + s);
103+
try {
104+
return DEFAULT_JSON_PARSER.parseJSON(json);
105+
} catch (Throwable e) {
106+
throw new IllegalArgumentException("JSON 格式错误!" + e.getMessage() + "! " + s);
107+
}
104108
}
105109

106110
/**

APIJSONORM/src/main/java/apijson/JSONField.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

APIJSONORM/src/main/java/apijson/JSONParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.List;
99
import java.util.Map;
1010

11-
/**SQL相关创建器
11+
/**JSON 相关解析器
1212
* @author Lemon
1313
*/
1414
public interface JSONParser<M extends Map<String, Object>, L extends List<Object>> extends JSONCreator<M, L> {

APIJSONORM/src/main/java/apijson/orm/AbstractFunctionParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ public static <T, M extends Map<String, Object>, L extends List<Object>> Object
488488
* @throws Exception
489489
*/
490490
@SuppressWarnings({"unchecked", "rawtypes"})
491-
public static <T, M extends Map<String, Object>, L extends List<Object>> Object invoke(@NotNull AbstractFunctionParser<T, M, L> parser, @NotNull String methodName
491+
public static <T, M extends Map<String, Object>, L extends List<Object>> Object invoke(
492+
@NotNull AbstractFunctionParser<T, M, L> parser, @NotNull String methodName
492493
, @NotNull Class<?>[] parameterTypes, @NotNull Object[] args, String returnType
493494
, Map<String, Object> current, ScriptExecutor scriptExecutor) throws Exception {
494495
if (scriptExecutor != null) {

APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,10 @@ public AbstractObjectParser<T, M, L> parse(String name, boolean isReuse) throws
256256
break;
257257
}
258258

259-
// key可能为JSONArray,需要进行手动转换(fastjson为低版本时允许自动转换,如1.2.21)
260-
// 例如request json为 "{[]:{"page": 2, "table1":{}}}"
259+
// key 可能为 JSONArray,需要进行手动转换(fastjson 为低版本时允许自动转换,如 1.2.21)
260+
// 例如 request json为 "{[]:{"page": 2, "table1":{}}}"
261261
Object field = entry == null ? null : entry.getKey();
262-
String key = field instanceof JSONArray ? ((JSONArray) field).toJSONString() : field.toString();
262+
String key = field instanceof Map ? toJSONString(field) : field.toString();
263263
Object value = key == null ? null : entry.getValue();
264264
if (value == null) {
265265
continue;

APIJSONORM/src/main/java/apijson/orm/JSONRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public Object put(String key, Object value) {
8585
try {
8686
target = JSON.parseJSON(value);
8787
} catch (Exception e) {
88-
throw new RuntimeException(e);
88+
// nothing
89+
e.printStackTrace();
8990
}
9091
// if (target == null) { // "tag":"User" 报错
9192
// return null;

APIJSONORM/src/main/java/apijson/orm/Subquery.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
package apijson.orm;
77

8-
import apijson.JSONField;
9-
108
import java.util.List;
119
import java.util.Map;
1210

0 commit comments

Comments
 (0)