fastjson JSON.parseObject(String text, Class< T> clazz) 对于 _xxx 字段无法赋值

iyr7buue  于 2021-11-27  发布在  Java
关注(0)|答案(2)|浏览(440)
  • No description provided.*
l2osamch

l2osamch1#

可以的 升级到最新版本试一下

public class Issue3293 extends TestCase {
    public void test_for_issue() throws Exception {
        String s = "{ \"componentKey\" : \"CMDB_UPDATE_SERVER\"}";
        Step step = JSON.parseObject(s, Step.class);
        Assert.assertEquals("CMDB_UPDATE_SERVER",step.get_componentKey());
    }
    private static class Step {
        private String _componentKey;

        public String get_componentKey() {
            return _componentKey;
        }

        public void set_componentKey(String _componentKey) {
            this._componentKey = _componentKey;
        }
    }
}
shyt4zoc

shyt4zoc2#

再次测试后,1.2.29 存在该问题, 1.2.39-->及最新版未复现, 感谢 @biyanwen

相关问题