修改fastjson2序列化时将byte[]序列化为Base64字符串,反之在反序列化时将Base64字符串反序列化为byte[]
This commit is contained in:
parent
c046a52214
commit
37445a2723
@ -3,6 +3,7 @@ package club.joylink.xiannccda.configuration;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONReader;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.alibaba.fastjson2.JSONWriter.Feature;
|
||||
import com.alibaba.fastjson2.reader.ObjectReader;
|
||||
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
|
||||
import com.alibaba.fastjson2.writer.ObjectWriter;
|
||||
@ -22,6 +23,8 @@ public class JsonConfig implements ApplicationRunner {
|
||||
@Bean
|
||||
public HttpMessageConverters fastJsonHttpMessageConverters() {
|
||||
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
|
||||
converter.getFastJsonConfig().setWriterFeatures(Feature.WriteByteArrayAsBase64);
|
||||
converter.getFastJsonConfig().setReaderFeatures(JSONReader.Feature.Base64StringAsByteArray);
|
||||
return new HttpMessageConverters(converter);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user