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

实体类字段超过32个解析不了 #1490

Open
ozy1996 opened this issue May 17, 2023 · 5 comments
Open

实体类字段超过32个解析不了 #1490

ozy1996 opened this issue May 17, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ozy1996
Copy link

ozy1996 commented May 17, 2023

字段超过32个,Retrofit2ConverterFactory中解析报错。
然后JSON.parseObject(byteArray, Test.class) 这个解析json的也会报错

implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.32")
implementation("com.alibaba.fastjson2:fastjson2-extension:2.0.32")

@ozy1996 ozy1996 added the bug Something isn't working label May 17, 2023
@wenshao
Copy link
Member

wenshao commented May 17, 2023

有测试超过1000+字段的,能提供重现问题的testcase和错误信息么?

@ozy1996
Copy link
Author

ozy1996 commented May 18, 2023

有测试超过1000+字段的,能提供重现问题的测试用例和错误信息吗?

32个及以下就可以。超过32个就解析不了了。

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.alibaba.fastjson2.JSON
import com.alibaba.fastjson2.parseObject
import com.alibaba.fastjson2.support.retrofit.Retrofit2ConverterFactory

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val json = """
            {
                "field1":"1"
            }
        """.trimIndent()
        try {
            val data1 = json.parseObject<Entity>()
            Log.w("=========>>", "======>>>data1:$data1")
//            val data2 = JSON.parseObject(json.toByteArray(), Entity::class.java)
//            Log.w("=========>>", "======>>>data2:$data2")
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}


data class Entity(
    val field1: String = "",
    val field2: String = "",
    val field3: String = "",
    val field4: String = "",
    val field5: String = "",
    val field6: String = "",
    val field7: String = "",
    val field8: String = "",
    val field9: String = "",
    val field10: String = "",
    val field11: String = "",
    val field12: String = "",
    val field13: String = "",
    val field14: String = "",
    val field15: String = "",
    val field16: String = "",
    val field17: String = "",
    val field18: String = "",
    val field19: String = "",
    val field20: String = "",
    val field21: String = "",
    val field22: String = "",
    val field23: String = "",
    val field24: String = "",
    val field25: String = "",
    val field26: String = "",
    val field27: String = "",
    val field28: String = "",
    val field29: String = "",
    val field30: String = "",
    val field31: String = "",
    val field32: String = "",
    val field33: String = "",
)

kraity added a commit to kraity/fastjson2 that referenced this issue May 18, 2023
Signed-off-by: Kraity <kraty@krait.cn>
wenshao pushed a commit that referenced this issue May 18, 2023
Signed-off-by: Kraity <kraty@krait.cn>
@wenshao
Copy link
Member

wenshao commented May 18, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.33-SNAPSHOT/
问题已修复,请帮忙用2.0.33-SNAPSHOT版本验证。

@wenshao wenshao added this to the 2.0.33 milestone May 18, 2023
@wenshao wenshao added the fixed label May 18, 2023
@ozy1996
Copy link
Author

ozy1996 commented May 19, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.33-SNAPSHOT/ 问题已修复,请帮忙用2.0.33-SNAPSHOT版本验证。

还是不行,实体类是data class 不行,如果是普通的class就可以,这个和 #1491 差不多

@wenshao
Copy link
Member

wenshao commented May 29, 2023

https://github.com/alibaba/fastjson2/releases/tag/2.0.33
请帮忙用新版本验证

@wenshao wenshao modified the milestones: 2.0.33, 2.0.34 May 29, 2023
@wenshao wenshao modified the milestones: 2.0.34, 2.0.35 Jun 18, 2023
@wenshao wenshao modified the milestones: 2.0.35, 2.0.36 Jul 8, 2023
@wenshao wenshao modified the milestones: 2.0.36, 2.0.37, 2.0.38 Jul 18, 2023
@wenshao wenshao modified the milestones: 2.0.38, 2.0.39 Jul 29, 2023
@wenshao wenshao removed the fixed label Aug 13, 2023
@wenshao wenshao modified the milestones: 2.0.39, 2.0.40 Aug 15, 2023
@wenshao wenshao modified the milestones: 2.0.40, 2.0.41 Sep 3, 2023
@wenshao wenshao removed this from the 2.0.41 milestone Oct 5, 2023
@wenshao wenshao added this to the 2.0.42 milestone Oct 5, 2023
@wenshao wenshao modified the milestones: 2.0.42, 2.0.43 Oct 29, 2023
@wenshao wenshao modified the milestones: 2.0.43, 2.0.44 Dec 3, 2023
@wenshao wenshao modified the milestones: 2.0.44, 2.0.45 Dec 23, 2023
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

3 participants