Skip to content

[QUESTION] toJSONString 序列化时默认忽略 private 字段,有没有办法不忽略? #3287

@EmptyDreams

Description

@EmptyDreams

现在我有这样一个类:

data class Test(
    @JSONField(serialize = true, deserialize = true)
    private val a: Int,
    val b: Int
)

当我使用 Test(1, 2).toJSONString() 序列化类时,a 会被忽略。

默认忽略 private 我认为没有什么问题,但是在主动标注 JSONField 后是否应该优先使用 JSONField 中的设置?

目前版本是否有办法绕过 private 检查?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfixedquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions