perf: 优化代码
This commit is contained in:
@@ -1,16 +1,12 @@
|
|||||||
package com.tiesheng.util;
|
package com.tiesheng.util;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.serializer.SerializeFilter;
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||||
import com.tiesheng.util.config.desensitize.DesensitizeValueFilter;
|
import com.tiesheng.util.config.desensitize.DesensitizeValueFilter;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CommonUtil {
|
public class CommonUtil {
|
||||||
|
|
||||||
@@ -40,13 +36,10 @@ public class CommonUtil {
|
|||||||
*/
|
*/
|
||||||
public static String writeJsonString(Object value) throws IOException {
|
public static String writeJsonString(Object value) throws IOException {
|
||||||
FastJsonConfig fastJsonConfig = fastJsonConfig();
|
FastJsonConfig fastJsonConfig = fastJsonConfig();
|
||||||
SerializeFilter[] globalFilters = fastJsonConfig.getSerializeFilters();
|
|
||||||
List<SerializeFilter> allFilters = new ArrayList(Arrays.asList(globalFilters));
|
|
||||||
|
|
||||||
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
|
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
|
||||||
JSON.writeJSONStringWithFastJsonConfig(outnew, fastJsonConfig.getCharset(),
|
JSON.writeJSONStringWithFastJsonConfig(outnew, fastJsonConfig.getCharset(),
|
||||||
value, fastJsonConfig.getSerializeConfig(),
|
value, fastJsonConfig.getSerializeConfig(),
|
||||||
allFilters.toArray(new SerializeFilter[allFilters.size()]),
|
fastJsonConfig.getSerializeFilters(),
|
||||||
fastJsonConfig.getDateFormat(), JSON.DEFAULT_GENERATE_FEATURE,
|
fastJsonConfig.getDateFormat(), JSON.DEFAULT_GENERATE_FEATURE,
|
||||||
fastJsonConfig.getSerializerFeatures());
|
fastJsonConfig.getSerializerFeatures());
|
||||||
return outnew.toString();
|
return outnew.toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user