refactor: Jackson配置优化

Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
fit2-zhao 2023-06-27 13:36:07 +08:00 committed by fit2-zhao
parent 3e062da560
commit 1e82da6309
4 changed files with 8 additions and 2 deletions

View File

@ -46,6 +46,8 @@ public class JSONUtil {
// 如果一个对象中没有任何的属性那么在序列化的时候就会报错 // 如果一个对象中没有任何的属性那么在序列化的时候就会报错
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
// 使用BigDecimal来序列化
objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
// 设置JSON处理字符长度限制 // 设置JSON处理字符长度限制
objectMapper.getFactory() objectMapper.getFactory()
.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(JSON.DEFAULT_MAX_STRING_LEN).build()); .setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(JSON.DEFAULT_MAX_STRING_LEN).build());

View File

@ -348,7 +348,7 @@ export default {
this.report = response.data || {}; this.report = response.data || {};
if (response.data) { if (response.data) {
if (response.data.status === 'RUNNING') { if (response.data.status === 'RUNNING') {
setTimeout(this.getReport, 5000); setTimeout(this.getReport, 2000);
} else { } else {
this.content = JSON.parse(response.data.content); this.content = JSON.parse(response.data.content);
if (!this.content) { if (!this.content) {
@ -512,7 +512,7 @@ export default {
} }
if (e.data && e.data.indexOf('MS_TEST_END') !== -1) { if (e.data && e.data.indexOf('MS_TEST_END') !== -1) {
this.getReport(); setTimeout(this.getReport, 3000);
this.messageWebSocket.close(); this.messageWebSocket.close();
this.cleanHeartBeat(); this.cleanHeartBeat();
this.$EventBus.$emit('hide', this.scenarioId); this.$EventBus.$emit('hide', this.scenarioId);

View File

@ -24,6 +24,8 @@ public class JsonUtils {
// 如果一个对象中没有任何的属性那么在序列化的时候就会报错 // 如果一个对象中没有任何的属性那么在序列化的时候就会报错
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
// 使用BigDecimal来序列化
objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
// 设置JSON处理字符长度限制 // 设置JSON处理字符长度限制
objectMapper.getFactory() objectMapper.getFactory()
.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build()); .setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());

View File

@ -29,6 +29,8 @@ public class JSON {
// 如果一个对象中没有任何的属性那么在序列化的时候就会报错 // 如果一个对象中没有任何的属性那么在序列化的时候就会报错
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
// 使用BigDecimal来序列化
objectMapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);
// 设置JSON处理字符长度限制 // 设置JSON处理字符长度限制
objectMapper.getFactory() objectMapper.getFactory()
.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build()); .setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());