fastjson2
fastjson2 copied to clipboard
[BUG] Parse similar attributes with underline
问题描述
https://github.com/alibaba/fastjson/issues/1089 ,fastjson兼容依旧存在此问题。
环境信息
- OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
- JDK信息: [Openjdk 17.0.6]
- 版本信息:[Fastjson 2.0.51]
重现步骤
import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Created by wenshao on 20/03/2017.
*/
public class Issue1089 {
@Test
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
public static class TestBean {
private int ab;
public int getAb() {
return ab;
}
public void setAb(int ab) {
this.ab = ab;
}
}
}
相关日志输出
Expected :123 Actual :456