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
kotlin data class 和泛型JSON.parseObject<Entity>(json)的bug[BUG] #1491
Comments
您好, 麻烦提供一下Android版本, 日志是否类似有 |
您好,这是我的demo http://cloud.file.tdconnect.cn/upload/2023-05-19/2d1a2616-cd38-4ec8-8a62-2976cbac0aeb.zip |
implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.33") 验证结果:
1. 使用val data = JSON.parseObject(json,Entity::class.java),如果Entity为data class,字段有默认值,解析不会报错,但是解析不出来字段没赋值。字段没有默认值,会报错,如果Entity为普通的class则正常解析
2. 使用val data = JSON.parseObject<Entity>(json),不管是data class 还是普通class 都会报错 val data = JSON.parseObject<Entity>(json)报错日志
|
这个demo无法下载 |
复制url粘贴到浏览器地址栏就可以下载了 |
@ozy1996 并非BUG, 报错原因为: 调用错误、缺少反射库, 如下 调用错误: 缺少反射库: 正确使用方式: val text = """
{
"age":5,
"name":"1234243"
} 1. 同时若使用 @wenshao 温少, 在kotlin中调用 |
kotlin 中解析 data class的问题,是不支持kotlin还是bug呢
日志信息
The text was updated successfully, but these errors were encountered: