diff --git a/src/main/java/com/alibaba/fastjson/util/DeserializeBeanInfo.java b/src/main/java/com/alibaba/fastjson/util/DeserializeBeanInfo.java index 97d7b608b..77b2d3f83 100755 --- a/src/main/java/com/alibaba/fastjson/util/DeserializeBeanInfo.java +++ b/src/main/java/com/alibaba/fastjson/util/DeserializeBeanInfo.java @@ -217,6 +217,8 @@ public class DeserializeBeanInfo { propertyName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); } else if (c3 == '_') { propertyName = methodName.substring(4); + } else if (c3 == 'f') { + propertyName = methodName.substring(3); } else { continue; } diff --git a/src/main/java/com/alibaba/fastjson/util/TypeUtils.java b/src/main/java/com/alibaba/fastjson/util/TypeUtils.java index 27575f874..1c9434954 100755 --- a/src/main/java/com/alibaba/fastjson/util/TypeUtils.java +++ b/src/main/java/com/alibaba/fastjson/util/TypeUtils.java @@ -944,6 +944,8 @@ public class TypeUtils { propertyName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4); } else if (c3 == '_') { propertyName = methodName.substring(4); + } else if (c3 == 'f') { + propertyName = methodName.substring(3); } else { continue; } @@ -994,13 +996,20 @@ public class TypeUtils { if (methodName.length() < 3) { continue; } + + char c2 = methodName.charAt(2); - if (!Character.isUpperCase(methodName.charAt(2))) { + String propertyName; + if (Character.isUpperCase(c2)) { + propertyName = Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3); + } else if (c2 == '_') { + propertyName = methodName.substring(3); + } else if (c2 == 'f') { + propertyName = methodName.substring(2); + } else { continue; } - String propertyName = Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3); - Field field = ParserConfig.getField(clazz, propertyName); if (field != null) { JSONField fieldAnnotation = field.getAnnotation(JSONField.class); diff --git a/src/test/java/com/alibaba/json/bvt/fullSer/getfTest.java b/src/test/java/com/alibaba/json/bvt/fullSer/getfTest.java new file mode 100644 index 000000000..2b9104e83 --- /dev/null +++ b/src/test/java/com/alibaba/json/bvt/fullSer/getfTest.java @@ -0,0 +1,38 @@ +package com.alibaba.json.bvt.fullSer; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.fastjson.JSON; +import com.alibaba.json.bvt.fullSer.get_set_Test.VO; + +public class getfTest extends TestCase { + + public void test_codec() throws Exception { + VO vo = new VO(); + vo.setfId(123); + + String text = JSON.toJSONString(vo); + Assert.assertEquals("{\"fId\":123}", text); + VO vo1 = JSON.parseObject(text, VO.class); + Assert.assertEquals(123, vo1.getfId()); + } + + public static class VO { + + private int fId; + + + public int getfId() { + return fId; + } + + + public void setfId(int fId) { + this.fId = fId; + } + + + } +} diff --git a/src/test/java/com/alibaba/json/bvt/fullSer/getfTest_2.java b/src/test/java/com/alibaba/json/bvt/fullSer/getfTest_2.java new file mode 100644 index 000000000..a167f2136 --- /dev/null +++ b/src/test/java/com/alibaba/json/bvt/fullSer/getfTest_2.java @@ -0,0 +1,35 @@ +package com.alibaba.json.bvt.fullSer; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.fastjson.JSON; +import com.alibaba.json.bvt.fullSer.get_set_Test.VO; + +public class getfTest_2 extends TestCase { + + public void test_codec() throws Exception { + VO vo = new VO(); + vo.setfFlag(true); + + String text = JSON.toJSONString(vo); + Assert.assertEquals("{\"fFlag\":true}", text); + VO vo1 = JSON.parseObject(text, VO.class); + Assert.assertEquals(true, vo1.isfFlag()); + } + + public static class VO { + + private boolean fFlag; + + public boolean isfFlag() { + return fFlag; + } + + public void setfFlag(boolean fFlag) { + this.fFlag = fFlag; + } + + } +} diff --git a/src/test/java/com/alibaba/json/bvt/fullSer/is_set_test_2.java b/src/test/java/com/alibaba/json/bvt/fullSer/is_set_test_2.java new file mode 100644 index 000000000..3a9978b2c --- /dev/null +++ b/src/test/java/com/alibaba/json/bvt/fullSer/is_set_test_2.java @@ -0,0 +1,35 @@ +package com.alibaba.json.bvt.fullSer; + +import junit.framework.TestCase; + +import org.junit.Assert; + +import com.alibaba.fastjson.JSON; +import com.alibaba.json.bvt.fullSer.get_set_Test.VO; + +public class is_set_test_2 extends TestCase { + + public void test_codec() throws Exception { + VO vo = new VO(); + vo.set_flag(true); + + String text = JSON.toJSONString(vo); + Assert.assertEquals("{\"flag\":true}", text); + VO vo1 = JSON.parseObject(text, VO.class); + Assert.assertEquals(true, vo1.is_flag()); + } + + public static class VO { + + private boolean flag; + + public boolean is_flag() { + return flag; + } + + public void set_flag(boolean flag) { + this.flag = flag; + } + + } +}