/**
* 首字母小写
* author:wp
*/
public static Object keyFirstToLower(Object obj) throws Exception {
if(obj != null){
if(obj instanceof List){
List> list = (List>) obj;
List> listRes = new ArrayList>();
if(list != null && list.size() > 0){
for (Map map : list) {
listRes.add(toLower(map));
}
return listRes;
}
}else if(obj instanceof Map){
Map result = new HashMap();
Map map = (Map) obj;
if(map!= null && !map.isEmpty()){
result = toLower(map);
return result;
}
}
}
return null;
}
private static Map toLower(Map map) {
Map result = new HashMap();
try {
if(map != null && !map.isEmpty()){
Iterator> iterator = map.entrySet().iterator();
while(iterator.hasNext()) {
Map.Entry entry = iterator.next();
String key = entry.getKey();
Object value = entry.getValue();
String firstChar = String.valueOf(key.charAt(0));
key = key.replaceFirst(firstChar, firstChar.toLowerCase());
result.put(key, String.valueOf(entry.getValue()));
if(value instanceof List){
List> list = (List>) value;
List> listRes = new ArrayList>();
if(list != null && list.size() > 0){
for (Map map2 : list) {
Map mapres = (Map) keyFirstToLower(map2);
listRes.add(mapres);
}
result.put(key, listRes);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
logger.info("=========result"+result.toString());
return result;
}