fastjson CamelCase and UnderScoreCase is different when useing JavaBeanDeserializer and @JSONField in versions from (including) 1.2.71

nfeuvbwi  于 2021-11-27  发布在  Java
关注(0)|答案(0)|浏览(186)

why #3246 is a bug?

@Test
public void JSONObjectTest() {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("ab", "11");
    jsonObject.put("cd", "22");
    jsonObject.put("ef", "33");
    Lizz lizz = jsonObject.toJavaObject(Lizz.class);
    System.out.println(JSON.toJSONString(lizz));
    Assert.assertNotNull(lizz.getAb());
    Assert.assertNotNull(lizz.getCd());
    Assert.assertNotNull(lizz.getE_f());
}
@Data
static class Lizz {
    @JSONField(name = "a_b")
    private String ab;
    private String cd;
    private String e_f;
}

"ab" connot match "a_b" of JSONField, but "ef" can match "e_f" ,I think this is wrong。
I think the matching rules should be same。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题