feilong-core 1.9.3 发布了,feilong-core 是一个让Java开发更简便的工具包。 简介: 目标:Reduce development, Release ideas 可以帮助你的代码更简短精炼,使它易写、易读、易于维护。 提高工作效率,让你从大量重复的底层代码中脱身。 特性 JsonFormatConfig add jsonTargetClassAndPropertyNameProcessorMap property, fix #505 add CapitalizePropertyNameProcessor JsonUtil 将对象转成json 字符串的时候,支持修改属性名称 下面是使用示例: 我们这边的代码 public class CrmAddpointCommand{ // 用户编码 private String openId; // 渠道:Tmall - 天猫 JD - 京东 private String consumptionChannel; // 淘宝/京东买家账号 private String buyerId; // 电商订单编号 private String orderCode; // setter getter } 符合标准的java代码规范,如果直接使用 com.feilong.tools.jsonlib.JsonUtil.format(Object) public void testJsonTest(){ CrmAddpointCommand crmAddpointCommand = new CrmAddpointCommand(); crmAddpointCommand.setBuyerId("123456"); crmAddpointCommand.setConsumptionChannel("feilongstore"); crmAddpointCommand.setOpenId("feilong888888ky"); crmAddpointCommand.setOrderCode("fl123456"); LOGGER.debug(JsonUtil.format(crmAddpointCommand)); } 输出结果: { "orderCode": "fl123456", "buyerId": "123456", "consumptionChannel": "feilongstore", "openId": "feilong888888ky" } 输出的属性大小写和 crmAddpointCommand 对象里面字段的大小写相同,但是对方接口要求首字符要大写: 此时,你可以使用 public void testJsonTest(){ CrmAddpointCommand crmAddpointCommand = new CrmAddpointCommand(); crmAddpointCommand.setBuyerId("123456"); crmAddpointCommand.setConsumptionChannel("feilongstore"); crmAddpointCommand.setOpenId("feilong888888ky"); crmAddpointCommand.setOrderCode("fl123456"); //**************************************************************************************** JsonFormatConfig jsonFormatConfig = new JsonFormatConfig(); Map<Class<?>, PropertyNameProcessor> targetClassAndPropertyNameProcessorMap = newHashMap(1); targetClassAndPropertyNameProcessorMap.put(CrmAddpointCommand.class, CapitalizePropertyNameProcessor.INSTANCE); jsonFormatConfig.setJsonTargetClassAndPropertyNameProcessorMap(targetClassAndPropertyNameProcessorMap); LOGGER.debug(JsonUtil.format(crmAddpointCommand, jsonFormatConfig)); } 输出结果: { "OrderCode": "fl123456", "BuyerId": "123456", "ConsumptionChannel": "feilongstore", "OpenId": "feilong888888ky" } 修改 update javadoc fix #508 移除 none Bug 修复 RegexPattern update MOBILEPHONE regex pattern to ^1[34578]\\d{9}$ fix #506,更多说明参见 javadoc 下载 Source code (zip) Source code (tar.gz) 发行说明 https://github.com/venusdrogon/feilong-core/releases feilong-core 1.9.3,让 Java 开发更简便的工具包下载地址