FastJson序列化配置
1.PropertyNamingStrategy.SnakeCase;
效果:userCode => user_code
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
2.PropertyNamingStrategy.CamelCase;
效果:驼峰命名法
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;
3.PropertyNamingStrategy.PascalCase;
效果:帕斯卡命名法--单词首字母大写
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.PascalCase;
4.PropertyNamingStrategy.KebabCase;
效果:userCode => user-code
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.KebabCase;
使用方法:
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
// pushDTO推送参数实体类
String json = JSON.toJSONString(pushDTO, serializeConfig);