Skip to content

Commit

Permalink
修复fastjson 解析类型装换错误
Browse files Browse the repository at this point in the history
  • Loading branch information
andanyoung committed Aug 9, 2023
1 parent 4fbbb25 commit dedd7eb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public <T> List<T> getArray(String key, Class<T> tClass) {
JSONArray jsonArray = jsonObject.getJSONArray(key);
List<T> jsonMappers = new ArrayList<>(jsonArray.size());
for (Object jsonObject : jsonArray) {
jsonMappers.add(((JSONObject) jsonObject).toJavaObject(tClass));
if (jsonObject instanceof JSONObject) {
jsonMappers.add(((JSONObject) jsonObject).toJavaObject(tClass));
} else {
jsonMappers.add((T) jsonObject);
}
}
return jsonMappers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public <T> List<T> getArray(String key, Class<T> tClass) {
JSONArray jsonArray = jsonObject.getJSONArray(key);
List<T> jsonMappers = new ArrayList<>(jsonArray.size());
for (Object jsonObject : jsonArray) {
jsonMappers.add(((JSONObject) jsonObject).toJavaObject(tClass));
if (jsonObject instanceof JSONObject) {
jsonMappers.add(((JSONObject) jsonObject).toJavaObject(tClass));
} else {
jsonMappers.add((T) jsonObject);
}
}
return jsonMappers;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</scm>

<properties>
<revision>0.7.0</revision>
<revision>0.7.1</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down

0 comments on commit dedd7eb

Please # to comment.