Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]fastjson1-compatible class cannot be converted to same class #699

Closed
icetimidus opened this issue Aug 18, 2022 · 2 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@icetimidus
Copy link

icetimidus commented Aug 18, 2022

fastjson1-compatible class cannot be converted to same class.

当JSONArray内部元素类型与转换的目标类型相同时,toJavaList()会转换失败抛出异常。

环境信息

  • OS信息: Windows [版本 10.0.19044.1889]
  • JDK信息: Oracle JDK 1.8.0_291
  • 版本信息:Fastjson2 2.0.11

重现步骤

JSONArray array = JSON.parseArray("[\"a\",\"b\",\"c\"]");
List<String> list = array.toJavaList(String.class);

期待的正确结果

正常转换不报错。

相关日志输出

Exception in thread "main" com.alibaba.fastjson2.JSONException: class java.lang.String cannot be converted to class java.lang.String
	at com.alibaba.fastjson.JSONArray.toJavaList(JSONArray.java:817)
	at TestFastJson.main(TestFastJson.java:26)

附加信息

@icetimidus icetimidus added the bug Something isn't working label Aug 18, 2022
@icetimidus icetimidus changed the title [BUG] [BUG]fastjson1-compatible class cannot be converted to same class Aug 18, 2022
wenshao added a commit that referenced this issue Aug 18, 2022
@wenshao wenshao added this to the 2.0.12 milestone Aug 18, 2022
@wenshao
Copy link
Member

wenshao commented Aug 18, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.12-SNAPSHOT/
问题已修复,请帮忙用2.0.12-SNAPSHOT版本验证,2.0.12版本预计在8月21日前发布

@wenshao
Copy link
Member

wenshao commented Aug 20, 2022

@wenshao wenshao closed this as completed Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants