perf:移除hutool-json,直接使用fastjson
This commit is contained in:
@@ -4,10 +4,8 @@ package com.tiesheng.util;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
public class CharacterUtils {
|
||||
|
||||
@@ -24,19 +22,24 @@ public class CharacterUtils {
|
||||
/**
|
||||
* 移除特殊字符
|
||||
*
|
||||
* @param o 类
|
||||
* @param o 类
|
||||
* @param searchStr 规则
|
||||
*/
|
||||
public static void removeSymbol(Object o, String searchStr) {
|
||||
JSONObject object = JSONUtil.parseObj(o, false);
|
||||
for (Map.Entry<String, Object> entry : object) {
|
||||
if (ObjectUtil.isEmpty(entry.getValue()) || StrUtil.equals("null", String.valueOf(entry.getValue()))) {
|
||||
entry.setValue("");
|
||||
JSONObject object = JSON.parseObject(JSON.toJSONString(o));
|
||||
for (String key : object.keySet()) {
|
||||
if (StrUtil.isEmpty(key)) {
|
||||
continue;
|
||||
}
|
||||
if (StrUtil.isNotEmpty(entry.getKey())) {
|
||||
entry.setValue(StrUtil.trim(StrUtil.replace(entry.getValue().toString(), searchStr, "")));
|
||||
|
||||
Object value = object.get(key);
|
||||
if (ObjectUtil.isEmpty(value) || StrUtil.equals("null", String.valueOf(value))) {
|
||||
object.put(key, "");
|
||||
continue;
|
||||
}
|
||||
|
||||
String replace = StrUtil.replace(String.valueOf(value), searchStr, "");
|
||||
object.put(key, StrUtil.trim(replace));
|
||||
}
|
||||
BeanUtil.copyProperties(object, o);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user