概述 今天遇见一个需求,需要对json数据进行下划线与驼峰格式之间进行转换,在Fastjson.Jackson.Gson都提供了转换的方式,在这里进行一下列举. User类: public class User { private String nameInfo; private String ageInfo; public String getNameInfo() { return nameInfo; } public void setNameInfo(String nameInfo) { t
实体类: import java.io.Serializable; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class User implements Serializable { /** * */ private static final long seria
# 下划线转驼峰 def str2Hump(text): arr = filter(None, text.lower().split('_')) res = '' j = 0 for i in arr: if j == 0: res = i else: res = res + i[0].upper() + i[1:] j += 1 return res
public static final char UNDERLINE='_'; public static String camelToUnderline(String param){ if (param==null||"".equals(param.trim())){ return ""; } int len=param.length(); StringBuilder sb=new StringBuilder(len); for (int i = 0; i <