You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
package any;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import java.util.List;
import java.util.Map;
public class Test {
static class Result<T> {
public T data;
public int code;
}
public static void main(String[] args) throws Exception {
String json = "{\"data\":[{}]}";
// 这一步缓存 Result.class 的解析器
JSON.parseObject(json, Result.class);
// 嵌套类型解析 Result<List<Map>>
Result res = JSON.parseObject(json, new TypeReference<Result<List<Map>>>() {});
// 返回了 class com.alibaba.fastjson.JSONArray
System.out.println(res.data.getClass());
}
}
fastjson 版本:1.2.76
问题:同时使用简单类型、嵌套类型解析时,会导致 嵌套类型解析 解析失败。
测试代码:
源代码:
com.alibaba.fastjson.parser.ParserConfig 617 行
The text was updated successfully, but these errors were encountered: