toJSONString替换为fastjson工具类
This commit is contained in:
@@ -54,11 +54,11 @@ public class TransFormMap {
|
||||
}
|
||||
return JsonMapper.toJsonString(jsonMap);
|
||||
} else {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("解析补全日志信息过程异常,异常信息:" + e + "\n" + message);
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ public class TransFormObject {
|
||||
}
|
||||
return JsonMapper.toJsonString(object);
|
||||
} else {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("解析补全日志信息过程异常,异常信息:" + e + "\n" + message);
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.zdjizhi.utils.general;
|
||||
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.zdjizhi.common.FlowWriteConfig;
|
||||
import com.zdjizhi.utils.JsonMapper;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
@@ -12,6 +14,8 @@ import com.zdjizhi.utils.json.JsonTypeUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue;
|
||||
|
||||
|
||||
/**
|
||||
* 描述:转换或补全工具类
|
||||
@@ -53,13 +57,19 @@ public class TransFormTypeMap {
|
||||
String param = strings[3];
|
||||
functionSet(function, jsonMap, appendToKeyName, appendToKeyValue, logValue, param);
|
||||
}
|
||||
return JsonMapper.toJsonString(jsonMap);
|
||||
// return JsonMapper.toJsonString(jsonMap);
|
||||
|
||||
//fastjson test
|
||||
return JSONObject.toJSONString(jsonMap,
|
||||
SerializerFeature.DisableCircularReferenceDetect
|
||||
,SerializerFeature.WriteNullStringAsEmpty
|
||||
,SerializerFeature.WriteNullNumberAsZero);
|
||||
} else {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
logger.error("解析补全日志信息过程异常,异常信息:" + e + "\n" + message);
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.zdjizhi.common.FlowWriteConfig;
|
||||
import org.apache.flink.api.common.serialization.SimpleStringSchema;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer;
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||
import org.apache.kafka.common.config.SslConfigs;
|
||||
|
||||
|
||||
@@ -26,7 +27,6 @@ public class Consumer {
|
||||
properties.put("max.partition.fetch.bytes", FlowWriteConfig.MAX_PARTITION_FETCH_BYTES);
|
||||
properties.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
properties.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
|
||||
|
||||
CertUtils.chooseCert(FlowWriteConfig.KAFKA_SOURCE_PROTOCOL,properties);
|
||||
|
||||
return properties;
|
||||
|
||||
@@ -43,6 +43,7 @@ public class Producer {
|
||||
|
||||
kafkaProducer.setLogFailuresOnly(false);
|
||||
|
||||
|
||||
// kafkaProducer.setWriteTimestampToKafka(true);
|
||||
|
||||
return kafkaProducer;
|
||||
|
||||
Reference in New Issue
Block a user