/**
* `将对象转为json格式,并将驼峰转为下划线`
*
* @param obj 需要转换的对象
* @return 转换后的JSONObject
*/
public static JSONObject conversionUnderline(Object obj) {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
return JSONObject.parseObject(mapper.writeValueAsString(obj));
} catch (Exception e) {
return null;
}
}
将对象转为json格式,并将驼峰转为下划线
最新推荐文章于 2024-03-27 14:35:00 发布