Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

json串中存在类似同名的字段时,反序列化获取数据异常 #4513

Open
LowAndroider opened this issue Jul 8, 2024 · 0 comments

Comments

@LowAndroider
Copy link

LowAndroider commented Jul 8, 2024

{
    "mchareaCode": [
    ],
    "mchAreaCode": [
        "5500",
        "5510",
        "985510"
    ]
}

直接反序列化到下面的实体类时,mchAreaCode会被赋值为 JSON串的mchareaCode值

@Data
class A {
    private JSONArray mchAreaCode;
}

加入JSONField,mchAreaCode还是会被赋值为 JSON串的mchareaCode值

@Data
class A {
    @JSONField(name = "mchAreaCode")
    private JSONArray mchAreaCode;
}

虽然知道JSON串数据有问题,但是这么个反序列化的逻辑问题应该更大
这里使用的fastjson版本为1.2.83

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant